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.
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)
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 a PHP 5.4 served website on a Plesk-based IIS 7.5 server. The app pool identity runs as IWAM_plesk but PHP runs as IUSR_username.
When I upload files, PHP can move the file and create a thumbnail from it, but the file doesn't gain the anonymous IWAM_plesk(default) permissions for browsers to read the file and thus the image (not the generated thumbnail) "cannot be read" when viewing the site.
How can I grant the correct permissions to the file after uploading?
Only a folder "replace permissions on all child objects" fixes the issue (or adding the user permissions directly to the file).
This is a problem of the upload_tmp_dir setting in php.ini. When moving a file during the upload process, the permission don't move with it. Create a project specific upload folder, set the users/groups as you need it and set this folder as upload_tmp_dir, either in php.ini or project specific.
The uploaded file will inherit the permissions of the folder.
Had this problem with the webplatform installer, which sets the upload_tmp_dir to C:\Windows\temp by default.
I recently moved a wordpress site from media temple's gs to their dedicated virtual server.
The file structure changed when I upload files. The permissions automatically upload as 644 and I'd like to change this. Where should I look to change this, the php.ini file or somewhere ont he server settings? It uses plesk.
You're going to want to find a way to change your umask. You might have to talk to your server administrator about it, if you don't have shell access.
I have a plesk panel and root dedicated server on 1and1. I'm using custom programed php script to upload the files and create the folders to server. I have the upload folder named upload_data_folder with the 777 permission.
The scenario is the following:
I want to create folder in my upload_data_folder and than upload files in that newly crated folder. I'm doing this over php script so every file or folder that I create has apache user and the group as the owner.
I'm successfully crate the folder in my upload_data_folder and that folder is owned by apache, has apache as a group and has 777 premission. Then When I try to upload some files to that newly created folder It can't.
I think the problem is with some owner permission but if anyone has some idea what this can be I would be very grateful
It was my custom made script. huuu I solved the problem. The php safe mode was turned on. After I turned it off everything works perfectly.
By default apache document root is /var/www/html/. If plesk is installed document root will have a path like:/var/www/httpdocs for non-secure sites. Thus secure sites are stored in /var/www/httpsdocs.