PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, January 5, 2022

[FIXED] Retrieving images from database after uploaded using cakephp3

 January 05, 2022     cakephp-3.0, php     No comments   

Issue

use Cake\ORM\TableRegistry;

$websites => TableRegistry::get('Websites');

$query => $websites->find()->order(['creation_date' => 'DESC']);

  echo "<table>";
    echo"<tr>
           <td>Cover Image</td>
           <td>Company Name</td>
           <td>Date Added</td> 
         </tr>";
    foreach ($query as $row) {
    echo"<tr>
          <td>".$row['Website']['image']."</td>
          <td>".$row->company."</td
          <td>".$row->creation_date."</td>            </tr>";
    }      
 echo"</table>";

?>      
      I remember this code in cakephp2 and display the images path "app/webroot/img/websites/"
    <?php echo $this->Html->image('websites/' . $row['Website']['image']);

But how to do it in cakephp3 , to display the image. ?>


Solution

You seem to not know your real problem. Your question seems to be of someone struggling with the right HTML code to upload images. For that you just have to give to that uploading field in database table columna varchar type and then in the view where to upload the image from a file type to that field. Something like:

<div class="form-group">

       <?php
            echo $this->Form->input('your_column_name', [ 'type' => 'file']); 
        ?>
</Div>

But if your question is about not being able to retrieve or send to index.ctp or to a frontend view the uploaded image, then your solution is here: How to retrieve in cakephp3.7 the name as string of an image uploaded trough a form with blob column into a mysql database?



Answered By - Himmels DJ
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing