Hello
I have a web page where I placed a File Upload box.
When the user selects a file from their computer, then clicks the ‘Upload’ button, my script is suppose to copy this file to my ‘Uploads’ directory
on the server. However it is not working and I can’t figure out
why.
The ‘Uploads’ directory on the server is located in the root directory
and has the appropriate permissions.
Any help would be appreciated.
UploadMe.php
<?php
$sPath = 'http://eastcoasttechwriter.ca/wp-content/plugins/UploadMe/upload_image.php';
print ("Click the <b>Browse</b> button to select a file to upload. Click the <b>Upload</b> button to copy the file to the server.<br><br>");
print ("<form action='$sPath' method='post' enctype='multipart/form-data'>");
print ("<table border=0 width=400>");
print ("<tr>");
print (" <td>");
print (" <label for='file'>Filename:</label>");
print (" </td>");
print ("</tr>");
print ("<tr>");
print (" <td>");
print ("<input class='InputStyle' type='file' name='ufile' id='file' size=50 maxlength=80 /> ");
print (" </td>");
print ("</tr>");
print ("<tr>");
print (" <td>");
print (" ");
print (" </td>");
print ("</tr>");
print ("<tr>");
print (" <td>");
print ("<input class='ButtonStyle' type='submit' name='submit' value=' Upload' /> ");
print (" </td>");
print ("</tr>");
print ("</table>");
print (" </form>");
?>
upload_image.php
<?php
$sTemp1 = $_FILES["ufile"]["name"];
$sCopyFrom = $_FILES["ufile"]["tmp_name"];
$sCopyTo = "/Uploads/" . $sTemp1;
$myDirectory = opendir(".") or die("Unable to open directory.");
$bValue = copy ($sCopyFrom, $sCopyTo);
print ("<br>---$myDirectory--<br>$sCopyFrom : $sCopyTo<br><br>");
print ("--$bValue--<br>");
?>
Thanks.