php - print_r($_FILES); output is blank Array ( ) **.It means there is no file uploaded but i have uploaded the file -
i trying upload image code upload image given below :
if (!isset($_post['submit'])) { if (isset($_files['imageupload'])) { // image upload $target_dir = "c:/wamp64/www/images/"; $target_file = $target_dir . basename($_files["imageupload"]["name"]); echo 'your tmp location of img file ' . $_files['imageupload']['tmp_name'] . '<br>'; $imagetmp = addslashes(file_get_contents($_files['imageupload']['tmp_name'])); if (isset($_files['imageupload'])) { if (move_uploaded_file($_files["imageupload"]["tmp_name"], $target_file)) { echo "the file " . basename($_files["imageupload"]["name"]) . " has been uploaded."; } else { echo "sorry, there error uploading file."; } } $image = basename($_files["imageupload"]["name"], ".jpg"); $imagename = addslashes($_files['imageupload']['name']); } $query = "insert `form_details` (firstname,secondname,location,designation,fileno,doa,doj,cardtype1,cardcolor,cardtype2,door1,door2,door3,door4,door5,door6,door7,door8,door9,door10,door11,door12,imagetmp,imagename) values('$firstname','$secondname','$location','$designation','$fileno','$doa','$doj','$cardtype1','$cardcolor','$cardtype2','$door1','$door2','$door3','$door4','$door5','$door6','$door7','$door8','$door9','$door10','$door11','$door12','$imagetmp','$imagename')"; //query if (mysqli_query($connect, $query)) { //check query executed or not echo 'inserted' . '<br>'; } else { echo "problem occur" . mysqli_error($connect); } } else { echo "form values required"; }
undefined index: imageupload in
file_get_contents(): filename cannot empty
2 errors.
i have tried isset
, doesn't work . print_r($_files);
output blank array ( )
. means there no file uploaded have uploaded file.
i not able add picture given location
i able execute query successful doesn't upload pic database .
my code photo
<div class="form-inline"> <label for="passportcopy">passport copy</label> <input type="file" class="form-control" name="imageupload"/> </div>
try removing !
in first isset
if(isset($_post['submit'])){ //...other codes }
Comments
Post a Comment