I'm trying to make an uploader for my website. I followed some directions I found online. Whenever I go to upload it, it says this: Warning: move_uploaded_file(/Stuart/cookie.txt) [function.move-uploaded-file]: failed to open stream: No such file or directory in C:\Program Files\Abyss Web Server\htdocs\Start\upload\upload.php on line 23 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\Documents and Settings\Peg Stu and Naji\Local Settings\Temp\php487.tmp' to '/Stuart/cookie.txt' in C:\Program Files\Abyss Web Server\htdocs\Start\upload\upload.php on line 23 Sorry, there was a problem uploading your file. /I] My php script is: <?php $target = "/Stuart/"; $target = $target . basename( $_FILES['uploaded']['name']) ; $ok=1; //This is our size condition if ($uploaded_size > 1000000) { echo "Your file is too large. You might be a Hacker!.<br>"; $ok=0; } //Here we check that $ok was not set to 0 by an error if ($ok==0) { Echo "Sorry your file was not uploaded"; } //If everything is ok we try to upload it else { if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { echo "The file has been uploaded!"; } else { echo "Sorry, there was a problem uploading your file."; } } ?> I am unfamiliar with php. Does anyone know what is wrong?
This could be because of directory permissions. Can you try this? <?php if(isset($_FILES['uploaded'])){ $target = "galleries/".basename($_FILES['uploaded']['name']) ; print_r($_FILES); if(move_uploaded_file($_FILES['uploaded']['tmp_name'],$target)) echo "OK!";//$chmod o+rw galleries } else{ echo "<form enctype='multipart/form-data' action='CodeTool.php' method='POST'>"; echo "File:<input name='uploaded' type='file'/><input type='submit' value='Upload'/>"; echo "</form>"; } ?>