Note that there are some explanatory texts on larger screens.

plurals
  1. POUploaded images to mysql database, but can I retrieve it for an edit page?
    text
    copied!<pre><code>$fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_name']; $fileSize = $_FILES['userfile']['size']; $fileType = $_FILES['userfile']['type']; $fp = fopen($tmpName, 'r'); $content = fread($fp, filesize($tmpName)); $content = addslashes($content); fclose($fp); if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); } $fileName_th = $_FILES['thumbnail']['name']; $tmpName_th = $_FILES['thumbnail']['tmp_name']; $fileSize_th = $_FILES['thumbnail']['size']; $fileType_th = $_FILES['thumbnail']['type']; $fp_th = fopen($tmpName_th, 'r'); $content_th = fread($fp_th, filesize($tmpName_th)); $content_th = addslashes($content_th); fclose($fp_th); if(!get_magic_quotes_gpc()) { $fileName_th = addslashes($fileName_th); } $query = "INSERT INTO Images (profile_id, thumb, name, size, type, content ) ". "VALUES ('$profile_id', 0, '$fileName', '$fileSize', '$fileType', '$content'),('$profile_id', 1, '$fileName_th', '$fileSize_th', '$fileType_th', '$content_th') "; $r = mysqli_query($dbc, $query); echo "&lt;br&gt;$first_name uploaded successfully"; </code></pre> <p>That is the method im using to upload my images to my database. Now, what I want to do is to have an edit page which edits my form elements like text, along with making changes to the images.</p> <p>I know how to query text elements and place them back into their respective input fields, but how do i do that for files like images?</p> <p>Side question: What is the best way of "uploading" files to the database? Is it my way? Or is there a way of just writing files to a directory and saving the path in a database?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload