Permission denied when uploading file
I use this code to upload a document to my server.
<?php if ($_FILES["file"]["error"] > 0){ echo "Error: " . $_FILES["file"]["error"] . "<br>"; }else{ echo getcwd().'<br>'; echo "Upload in file named: " . $_FILES["file"]["name"] . "<br>"; $info = pathinfo($_FILES['userFile']['name']); $ext = pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION); $target = 'upload/100.'.$ext; move_uploaded_file( $_FILES['file']['tmp_name'], $target); } ?> I get an error message:
Warning: move_uploaded_file (C: \ Inetpub \ vhosts \ api.cutm.ac.in \ httpdocs \ UploadMarks \ upload \ 100.docx) [function.move-uploaded-file]: stream could not be opened: permission denied in C: \ Inetpub \ vhosts \ api.cutm.ac.in \ httpdocs \ UploadMarks \ uploadFile.php on line 14
Warning: move_uploaded_file () [function.move-uploaded-file]: Cannot move 'C: \ Windows \ Temp \ phpF64C.tmp' to 'C: \ Inetpub \ vhosts \ api.cutm.ac.in \ httpdocs \ UploadMarks \ upload \ 100.docx 'in the folder C: \ Inetpub \ vhosts \ api.cutm.ac.in \ httpdocs \ UploadMarks \ uploadFile.php on line 14
What am I doing wrong? What changes do I need in my code? Please help me in this regard.
The problem is that your folder does not have write permissions. And because of this, it does not download the file.
You must give him permission to record. You can also use chmod to grant write access to this folder.
Also check who has this write permission for this folder. When you download a file from code, it is loaded as the Other user.