Note that there are some explanatory texts on larger screens.

plurals
  1. POimage upload using php
    text
    copied!<p>I used this code to upload the picture. I got this code from stackoverflow. I am still unable to upload the image. I changed the db connection settings in table settings 2. I made the table but I am not sure whether the properties of the table I created are correct.</p> <pre><code>&lt;html&gt; &lt;head&gt;&lt;title&gt;Store Some Binary File to a DB&lt;/title&gt;&lt;/head&gt; &lt;body&gt; &lt;?php if ($submit) { $conn = mysql_connect("localhost", "your_username", "your_password") or die ("Error connecting to database."); mysql_select_db("your_database", $conn) or die ("error connecting to database."); $data = addslashes(file_get_contents($_FILES['form_data']['tmp_name']) $result = mysql_query ("INSERT INTO your_table ". "(description,bin_data,filename,filesize,filetype) ". "VALUES ('$form_description','$data','$form_data_name',". "'$form_data_size','$form_data_type')", $conn); $id = mysql_insert_id(); print "&lt;p&gt;This file has the following Database ID: &lt;b&gt;$id&lt;/b&gt;"; mysql_close(); } else { ?&gt; &lt;form method="post" action="&lt;?php echo $PHP_SELF; ?&gt;" enctype="multipart/form-data"&gt; File Description:&lt;br&gt; &lt;input type="text" name="form_description" size="40"&gt; &lt;input type="hidden" name="MAX_FILE_SIZE" value="1000000"&gt; &lt;br&gt;File to upload/store in database:&lt;br&gt; &lt;input type="file" name="form_data" size="40"&gt; &lt;p&gt;&lt;input type="submit" name="submit" value="submit"&gt; &lt;/form&gt; &lt;?php } ?&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Also, help me in retrieving the image from the database and showing it on a page.</p> <p>do u think thiis will work now?</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