PHP can't open uploaded files

时光毁灭记忆、已成空白 提交于 2019-12-11 12:32:00

问题


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


回答1:


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.




回答2:


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!




回答3:


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:

  1. Write permissions on the the folder through the IIS management console.
  2. Write permissions to IUSR_'server' in the folder's security settings.
  3. 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



来源:https://stackoverflow.com/questions/32937553/php-cant-open-uploaded-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!