Image upload in mysql
I want to know the simplest way to upload an image in to the database using php and display it back to my web page.If any one has the simplest code then please share it with me.
PHP page allowing the image file to be uploaded to an uploads directory. (Ensure its a valid image file and not a shell script that could allow hackers backdoor access to your site).
Once image is validated as true image. Store location of image in database. (e.g. - "images/image_file_name.jpg")
then call it through the display.php page in the <img src="$img" />
(keep in mind you have to run an SQL query to fetch the image location with a unique ID and attach it to the variable called $img.
If you want to store the actual data in the database take this as a sample http://stackoverflow.com/questions/6...as-a-blob-type
Thank you both of you ..
Originally Posted by manjuhugar24
you can store $encryptedContent in database, and when you want this image to display on webpage, simply use base64_decode(dbcolumn)
$tempFileName = $_FILES['attachFile']['tmp_name'];
$file = fopen($tempFileName, 'r');
$content = fread($file, filesize($tempFileName));
$encryptedContent = base64_encode($content);
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)