0

Display uploaded image in html

This is the important part of my code, why isnt the image being displayed? (i know some tags are missing like the body etc but i have all the missing tags in my file and its still not working) <?php if(isset($_POST['submit'])){ $file = $_FILES['file']; $fileName = $_FILES['file']['name']; $fileTmpName = $_FILES['file']['tmp_name']; $fileSize = $_FILES['file']['size']; $fileError = $_FILES['file']['error']; $fileType = $_FILES['file']['type']; $fileExt = explode('.',$fileName); $fileActualExt = strtolower(end($fileExt)); $allowed = array('jpg' , 'jpeg' , 'png' , 'pdf'); if(in_array($fileActualExt,$allowed)){ if($fileError === 0){ if($fileSize<1000000){ $fileNameNew = uniqid('',true).".".$fileActualExt; $fileDestination = 'uploads/'.$fileNameNew; move_uploaded_file($fileTmpName, $fileDestination); }else{ echo "Your file is too big!"; } }else{ echo "There was an error uploading the file"; } }else{ echo "You cannot upload files of this type!"; } } ?> <img src="<?php echo $fileNameNew;?>" width="250" height="250"/>

14th Feb 2018, 6:30 PM
Mogammad Shameer Losper
Mogammad Shameer Losper - avatar
1 Antwort
+ 1
Its okay, it worked after i replaced the name variable with the fileDestination variable.
14th Feb 2018, 7:04 PM
Mogammad Shameer Losper
Mogammad Shameer Losper - avatar