Reputation: 12431
I am on a shared-hosting account with GoDaddy it's a windows Server and I am getting this error when attempting to upload a file:
Warning: move_uploaded_file(D:\Hosting\6903\html\pdfs\ALDOmypdfAP.pdf) [function.move-uploaded-file]: failed to open stream: Permission denied in D:\Hosting\6903\html\back.php on line 436
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'D:\Temp\php\php98C.tmp' to 'D:\Hosting\6903\html\pdfs\ALDOmypdfAP.pdf
I have heard that I can set my php.ini file to change the directory that it's immediately being uploaded to, which would work, however I can't access my php.ini file.
I have tried to create my own php.ini file in the root of my directory, and it causes all sorts of problems, such as not finding the correct MySQL configuration files, goDaddy's support on this was to remove the custom php.ini file, ridiculous, I know.
I have tried to use ini_set like this
ini_set('upload_tmp_dir', 'D:/Hosting/6903/html/pdfs/');
But it hasn't made any effect. Do I have any other options here? Thank you!
UPDATE: From Coda the Octal permissions read 777 of the destination directory.
Upvotes: 4
Views: 17607
Reputation: 289
Maybe this can help...
Find and open php.ini in PHP folder (In my case c:\Program files(86)\PHP
)
Search for upload_tmp_dir
word and do one of two posibilities
--Posibility 1
3.1 Set upload_tmp_dir = "[Some folder with full permission for IUSR user]"
--Posibility 2
3.2 Search in windows explorer for the folder that is setted in upload_tmp_dir
(In my case C:\WINDOWS\Temp
)
3.2.1 Right click on C:\WINDOWS\Temp
-> Properties -> Security -> Edit button -> Add, then add IUSR user and set full permissions to this -> Accept button.
I think this can help someone.
Upvotes: 3
Reputation: 1636
Had the similar problem.
Fixed it by giving all permissions to usergroup "Authenticated User".
It took me couple of hours to realize it. This post kind of gave me the hint.
I hope my share will help others.
Upvotes: 3
Reputation: 878
As far as I know, you need to give the IUSR_MACHINENAME account write permissions specifically on the folder that you are trying to write to, or else it will fail. I don't know what Coda is, but can it allow you to set permissions for specific users?
Upvotes: 4
Reputation: 67685
The problem probably comes from the final destination directory more than the temporary directory.
Normally, if the file cannot be uploaded at all, $_FILES['yourfile']['error']
will be set to UPLOAD_ERR_CANT_WRITE (7). From the error message, it tells us the problem is that move_uploaded_file
can't either read from the temporary directory (unlikely), or write to the destination directory (most likely).
Check and maybe try changing the permissions on the destination directory.
Upvotes: 0