I have an upload script that runs on a windows webserver 2008. The uploads works nice, the file is created on the server. But when I try to access the uploaded image file via http, I just get an error 401. How can I resolve this?
EDIT: setting the chmod to 0777 after the file has been uploaded did not help, too.
That did it: https://serverfault.com/questions/85983/iis-iusrs-cannot-access-files-uploaded-and-created-by-network-service-error-401/229151#229151
For security reasons, many websites sequester uploaded files until they are validated, at which time they are made publicly accessible. If this is the cause, you'd have to ask the site's administration.
So to summarize : one of the solutions is :
Edit "upload_tmp_dir" inside of php.ini and for example set to "C:\my_temp_folder"
Than right click to folder and security tab than give modify permission to the IUSRS user ;)
Related
After having created a Wordpress website on a test server, I moved it to the clients server. The website works as intended, but now I cannot upload files anymore via the Wordpress media area: I am getting a message "Uploaded file could not be moved to Uploads/.../..." (not sure about the exact English terms here, I use a different language)
Both "servers" are actually just webspaces at different providers - I have no access to the server configuration.
I saw this question and its answers. Now, when I simply set file permissions of the "uploads" folder and all its contents to "777", uploading is possible again, but as is mentioned everywhere, this should not be done for security reasons.
The remaining solution would be to check if the owner of the folder and files is correct. Probably not, but: Where do I see the owner (in an FTP program like Filezilla) and how can I change it? Or what else could I do to solve this problem with the very limited possibilies I have (basically just FTP access, no control over server settings)?
FWIW: Via FTP (Filezilla) I have no problem uploading files to that directory.
Just to let interested users know: I contacted the providers support, they gave me the advice to update the account to a higher PHP version (by putting two lines into .htaccess, which I didn't know was possible), and now the problem is gone - I can upload files again, with the regular 755 setting for file permissions on the "upload folder" and its subfolders.
(BTW: PHP was 5.2(!), now 7)
So this is what's happening. I don't know how to explain this.
I made a software which uploads file to my website's FTP location. It's working as it should.
As you can see in the folder that inside public_html/phphostrot.rviews.xyz/user_rot/ there are 2 php files. But when i visit the url http://phphostrot.rviews.xyz/ i get a blank page with inder of / and nothing else. And if i try to access http://phphostrot.rviews.xyz/user_rot/ I get 404 error. Even the link to the file is not working. I don't know what's the problem.
I think it's a issue with the file permissions. Have you configured your server to serve files from your public directory.
Try changing the ownership of the files to www or apache
app, img, wp-admin, wp-content, wp-includes?
check file permissions (+x), as #atefth said, check owner.
check webserver config. and check apache/nginx logs
I have Ubuntu Server with lamp.
When i uploading files like xls or images it works fine, but when I trying to open it says me that the Excel file was broken. Same thing happens with images
Is it possible that php changes the file?
Permissions for /var/www/publick_html/uploads is 777
well, I know,I use windows and maybe this is extremely OFF TOPIC, but I have a simililar problem with uploaded files and my experience can be usefull for other people.
In my case, the uploaded file can not be open because it was written first in
C:\Windows\Temp
and then moved to the upload directory, but my temp folder doesn t have permission to access to it. Infact, if I click on temp folder I see:
After I clicked "Continue", the problem has been solved!
The problem was in versions of apache and php.
Version of apache was 2.2 and php was 5.4
I upgraded my apache to 2.4 version and now it works fine.
This should solve your problem with being unable to open uploaded files with PHP on SQL SERVER. It solved mine.
You may come across the following problem using PHP on Microsoft IIS: getting permission denied errors from the move_uploaded_file function even when all the folder permissions seem correct. I had to set the following to get it to work:
Write permissions on the the folder through the IIS management console.
Write permissions to IUSR_'server' in the folder's security settings.
Write permissions to "Domain Users" in the folder's security settings.
The third setting was required because my application itself lives in a secure folder - using authentication (either Basic or Windows Integrated) to identify the users. When the uploads happen IIS seems to be checking that these users have write access to the folder, not just whether the web server (IUSR_'server') has access.
Also, remember to set "Execute Permissions" to "None" in the IIS management console, so that people can't upload a script file and then run it. (Other checks of the uploaded file are recommended as well but 'Execute None' is a good start.)
reference https://www.php.net/manual/en/features.file-upload.php
I have one issue in one of my site. When I upload an image, it creates a folder and then uploading images inside the folder. Creating folder is working fine for me, but image can not be uploaded. move_uploaded_files is returning false without any error message.
When I checked manually, All folders have proper 777 permission. When folder is created by my code, owner is "apache".
But, when I created a folder manually via ftp, then owner is my username "aayushi", for this folder, upload image is working fine.
Any idea how can I fix the issue? OR how can I give rights to "apache" owner to upload images...
Thanks in advance.
When a folder is created, the owner will be the user who created the folder - in your ftp client, this is the user you logged in as; in PHP, this will be the user the PHP script runs as (in this case, the apache user). Most likely, your problem is the umask setting of Apache when it creates these folders. Setting the umask is covered in the PHP manual.
If you can find a copy of Sklar and Trachtenberg's "PHP Cookbook" somewhere, check out Recipe 19.11 ("Making New Directories") for a bit more discussion on how this works - there may be other tutorials as well, but this is one I found to be pretty clear.
We have just moved a website to a new server, both servers are Windows Server 2003 running IIS as the web server.
When uploading images we require that the uploaded files have certain permissions for the NETWORK SERVICE account. Images are uploaded using PHP, they are then filtered by ImageMagick using the mogrify.exe binary for resizing purposes and placed in a new folder created by PHP.
The problem we are encountering is that the uploaded file does not inherit the NETWORK SERVICE permissions although the folder does.
I ran filemon to see any errors and get the following:
mogrify.exe:6396 OPEN C:\inetpub\wwwroot\example.com\data\334480\test.jpg ACCESS DENIED NT AUTHORITY\NETWORK SERVICE
The reason we require NETWORK SERVICE access is due to an ASP.NET script we use to resize the image on the fly. I've searched Google but cannot find a solution. Any ideas?
Managed to fix the issue, I changed the upload tmp dir in php.ini to C:\Test and gave Test the permissions I required, I had already made this change but on further inspection upload_tmp_dir is set twice in the php.ini file. Uploaded files inherit the permissions of the temporary directory.
Have you made sure the "NETWORK SERVICE" ACL applies to "This folder, sub-folders and files", wherever it is applied. Also, try making a new folder somewhere else with that same ACL and see if files created by PHP inherit the permission.