I have a folder known as “Mobile_App” and in that folder is a html page which contains a file input, a php script which uploads files, and a folder known as “ImageFiles”.
The problem is that the files are not being uploaded into the “ImageFiles”. What I want to know is that is the code below correct when it comes to uploading a file into the “Imagefiles” folder or is it incorrect and how can I get it working correctly?
Below is the php script which uploads a file (the file input is known as “fileImage”):
<?php
$destination_path = $_SERVER['DOCUMENT_ROOT']."/ImageFiles";
$result = 0;
$target_path = $destination_path . basename( $_FILES['fileImage']['name']);
if(move_uploaded_file($_FILES['fileImage']['tmp_name'], $target_path)) {
$result = 1;
}
sleep(1);
?>
First of all, you have no
/between the folder name and the file name. Secondly, you don’t need to have the document root. Corrected code: