after uploading the image to a folder. how to display the image..
its my upload.php
the image is uploading fine. but the image is not displaying. a small box only showing.
this part not working...
/* Displaying Image*/
$image=$_FILES["file"]["name"];
$img="upload/".$image;
echo 'user3214024user3214024
531 gold badge2 silver badges5 bronze badges
2
Try this:
header['Content-Type: image/jpeg'];
readfile[$imgPath];
answered Feb 11, 2014 at 13:28
ManuManu
9125 silver badges16 bronze badges
As you've already put "upload" in $img
$img="upload/".$image;
You don't need to put it in src anymore
echo 'Mario RadomananaMario Radomanana
1,6881 gold badge23 silver badges31 bronze badges
0
I have tried your code and its working finely just need to change the line
echo'';
answered Apr 9, 2015 at 16:22
You need:
echo '';
answered Feb 11, 2014 at 13:28
You mixed up some quotes. It should be :
$image = $_FILES["file"]["name"];
$img = "upload/".$image;
echo "putvandeputvande
14.9k3 gold badges32 silver badges50 bronze badges
Don't put $img in quotations. When you do it the output is simply $img, not upload/...
echo < img src=" ' ,$img ,' ">;
Barnee
3,0248 gold badges41 silver badges48 bronze badges
answered Aug 13, 2014 at 10:21
We have to Put enctype = "multipart/form-data"
inside the form
- Sent file: echo $_FILES['image']['name'];
- File size: echo $_FILES['image']['size'];
- File type: echo $_FILES['image']['type']
-
We Have
//file_upload.php
if[isset[$_FILES['image']]]{$errors= array[];
$file_name = $_FILES['image']['name'];
$file_size = $_FILES['image']['size'];
$file_tmp = $_FILES['image']['tmp_name'];
$file_type = $_FILES['image']['type'];
$file_ext=strtolower[end[explode['.',$_FILES['image']['name']]]];
$extensions= array["jpeg","jpg","png"];
if[in_array[$file_ext,$extensions]=== false]{
$errors[]="extension not allowed, please choose a JPEG or PNG file.";
}
if[$file_size > 2097152] {
$errors[]='File size must be excately 2 MB';
}
if[empty[$errors]==true] {
move_uploaded_file[$file_tmp,"images/".$file_name];
echo "Success";
}else{
print_r[$errors];
} } ?>
answered Jun 19, 2019 at 17:20
Just do this
echo '
We have to take the $file_name
variable because.. ""
[double quotes] can only return text in the variable - it cannot return binary number to show image!
Wai Ha Lee
8,29772 gold badges59 silver badges88 bronze badges
answered Feb 21, 2018 at
13:46
How can I retrieve uploaded image in php?
STORE & RETRIEVE IMAGE IN DATABASE. STEP 1] CREATE A DATABASE TABLE. 1-database.sql. ... . STEP 2] PHP CONNECT TO DATABASE. 2-connect-db.php. ... . STEP 3] UPLOAD IMAGE TO DATABASE. 3-upload.php. ... . STEP 4] RETRIEVE & SHOW THE IMAGE. DIRECT IMAGE OUTPUT..
How do I find my uploaded files in php?
The is_uploaded_file[] function in PHP is an inbuilt function which is used to check whether the specified file uploaded via HTTP POST or not. The name of the file is sent as a parameter to the is_uploaded_file[] function and it returns True if the file is uploaded via HTTP POST.
How do I view an uploaded image in HTML?
How To Display Uploaded Image In Html Using Javascript ?. Hide file upload button from HTML page and replace it with a text or icon link. ... . Create a label for the file input field. ... . Javascript to display uploaded image in html. ... . Entire code block as a whole required to display uploaded image in html using javascript..
How display all images from database in php?
Explanation of PHP code:
We are first selecting the records from the table in the $query variable. Then the $result will execute the query. While loop is used to fetch all the records in the $data to fetch the image from the database. And finally, the fetched images are displayed with the help of the tag.