I'm implementing a simple php code to accept uploaded files and store them to the "uploads folder"
I've looked at a few answers on stackexchange including this (which is exactly the error I'm facing): WAMP: failed to open stream: No such file or directory
The error I'm getting is:
Warning: copy(speed.png): failed to open stream: No such file or directory in C:\Program Files\wamp\www\clientservertest\imageupload.php on line 6
My code is as follows:
<?php
if( $_FILES['UploadedPic']['name'] != "" )
{
$dirPath=dirname(__FILE__).'\uploads\temp.png';
copy( $_FILES["UploadedPic"]["name"], $dirPath ) or
die( "Could not copy file!$dirPath");
}
else
{
die("No file specified!");
}
?>
Its also printing the absolute path in $dirPath as:
C:\Program Files\wamp\www\clientservertest\uploads\temp.png
which is absolutely correct.
Really hoping for an answer! :)
EDIT: Code with move_uploaded_file:
<?php
if( $_FILES['UploadedPic']['name'] != "" )
{
$dirPath=dirname(__FILE__).'\uploads\temp.png';
move_uploaded_file( $_FILES["UploadedPic"]["name"], $dirPath ) or
die( "Could not copy file!$dirPath");
}
else
{
die("No file specified!");
}
?>
Error: Could not copy file!C:\Program Files\wamp\www\clientservertest\uploads\temp.png