Asked  7 Months ago    Answers:  5   Viewed   27 times

I am using 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 am getting these error message:

Warning: move_uploaded_file(C:Inetpubvhostsapi.cutm.ac.inhttpdocsUploadMarksupload100.docx) [function.move-uploaded-file]: failed to open stream: Permission denied in C:Inetpubvhostsapi.cutm.ac.inhttpdocsUploadMarksuploadFile.php on line 14

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:WindowsTempphpF64C.tmp' to 'C:Inetpubvhostsapi.cutm.ac.inhttpdocsUploadMarksupload100.docx' in C:Inetpubvhostsapi.cutm.ac.inhttpdocsUploadMarksuploadFile.php on line 14

What am I doing wrong? What changes do I need in my code? Please help me in this regard.

 Answers

87

The problem is that your folder is not having write permission. And because of that it is not uploading the file.

You have to give it write permission. You can also use chmod for giving write permission to that folder.

Also check who is having that write permission for that folder. When you upload the file from code it is uploaded as Other user.

More info

Wednesday, March 31, 2021
 
TheFrack
answered 7 Months ago
86

You should point to your vendor/autoload.php at Settings | PHP | PHPUnit when using PHPUnit via Composer.

This blog post has all the details (with pictures) to successfully configure IDE for such scenario: http://confluence.jetbrains.com/display/PhpStorm/PHPUnit+Installation+via+Composer+in+PhpStorm

Related usability ticket: http://youtrack.jetbrains.com/issue/WI-18388

P.S. The WI-18388 ticket is already fixed in v8.0

Wednesday, March 31, 2021
 
ojrac
answered 7 Months ago
79

On Mac OS X environment variables available in Terminal and for the normal applications can be different, check the related question for the solution how to make them similar.

Note that this solution will not work on Mountain Lion (10.8).

Saturday, May 29, 2021
 
Nate
answered 5 Months ago
73

Do f.mkdirs() before f.createNewFile(). You are probably trying to create a new file in a non-existent directory

Thursday, August 5, 2021
 
ajjumma
answered 3 Months ago
26

Looks like you need to check in the file build.sh with execution permissions. Please try the following from your own machine:

git update-index --add --chmod=+x build.sh
git commit -m 'Make build.sh executable'
git push
Saturday, September 4, 2021
 
NewPHP
answered 2 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :