HTML
<form enctype="multipart/form-data" id="SubmitForm" method="post" action="serv.php">
<input type="file" name="IMG" size="chars">
<input type="Submit" value="SAVE">
</form>
PHP
$target = 'upload/';
$target = $target . basename($_FILES['IMG']['name']);
if (move_uploaded_file($_FILES['IMG']['tmp_name'], $target)) { //line 66
echo 'File uploaded successfully';
} else {
echo 'Sorry, there was a problem uploading file'
}
PROBLEMS
Warning: move_uploaded_file(upload/image.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in C:\xampp\htdocs\test\include\pages\editor\ged.php on line 66
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\xampp\tmp\php5E.tmp' to 'upload/image.jpg' in C:\xampp\htdocs\test\include\pages\editor\ged.php on line 66
Sorry, there was a problem uploading file
I had added a file existence check and it passed, proving the file exists. I believe the problem lies somewhere within the PHP code I specified here.
Also, I've used a similar code on an earlier script and it worked. I expected this to be no different. I am beginning to think the problem is related to how the temporary file is handled? I do not know, which is why I'm here.
Apologies if this thread is a clone but all or any previous threads bearing a similar name provided solutions that did not prove to be useful for me (in my scenario).
Any help or advice is appreciated greatly. Where am I going wrong? And how can this be corrected?
upload/exist? Do you mean./upload/C:\xampp\htdocs\test\include\pages\editor\uploadexist?getcwd()to create the absolute path just in case, try not to hard code it, since it makes it hard to deploy the system on other machines.