简体   繁体   English

无法在Windows上打开PHP应用程序生成的文件

[英]Can't open files generated by PHP app on windows

I'm having a problem when I try to open files that were generated by my CMS on my windows machine. 尝试在Windows计算机上打开由CMS生成的文件时出现问题。 It has an upload function that saves the file on a given location (it is on my user folder, where I'm supposed to have all the write and read permissions). 它具有上载功能,可将文件保存在给定位置(该文件位于我的用户文件夹中,该文件夹应具有所有的读写权限)。

All I can see in that folder is a generic thumbnail, the ones generated by windows for each image type, PNGs and JPEGs in this case. 我在该文件夹中看到的只是一个普通缩略图,在这种情况下是Windows为每种图像类型(PNG和JPEG)生成的缩略图。 I tried to change de image permissions and set it to the current computer user but it doesn't work. 我试图更改de图像权限并将其设置为当前计算机用户,但是它不起作用。 And I'm unable to move these files to another location (upload them to the server via FTP). 而且我无法将这些文件移动到另一个位置(通过FTP将其上传到服务器)。

I wonder if there is a way to change this behavior. 我想知道是否有办法改变这种行为。

One thing I noticed is that if I copy and paste those files, I can see its contents normally. 我注意到的一件事是,如果我复制并粘贴这些文件,则可以正常看到其内容。 I know I can do that to each of them and rename, but there are dozens of images in that folder... don't wanna do the same thing everytime I upload a new image. 我知道我可以对每个人都执行此操作并重命名,但是该文件夹中有几十个图像...每次我上传新图像时都不想做同样的事情。

Update 更新

This is happening only to the images that were moved (I'm using php's move_uploaded_file function, btw), not to the ones that where generated (croped, resized and so on). 这仅发生在已移动的图像上(我使用的是php的move_uploaded_file函数,btw),而不发生在生成的图像上(裁剪,调整大小等)。

It`s happening because Windows keep file permissions of TEMP folder (usually c:/windows/temp) when moving a file. 这是因为Windows在移动文件时会保留TEMP文件夹的文件权限(通常为c:/ windows / temp)。 To prevent it you need to change "upload_tmp_dir" in "php.ini" to your server directory or set wide permissions to your windows temp folder. 为了防止出现这种情况,您需要将“ php.ini”中的“ upload_tmp_dir”更改为服务器目录,或者对Windows temp文件夹设置宽权限。

You probably have an error in some php file which is preventing the image from being displayed correctly. 您可能在某些php文件中有一个错误,导致图像无法正确显示。

What i would do in order to detect the problem is to comment out the header() calls in the php file responsible for displaying the image and see if there is any output other than the image data. 为了检测出该问题,我将注释掉负责显示图像的php文件中的header()调用,并查看是否有除图像数据以外的任何输出。

Inspect the whole output, it only takes a character to break everything, so check if there are no blank lines at the top or bottom of the output. 检查整个输出,只需要一个字符就可以破坏所有内容,因此请检查输出的顶部或底部是否没有空行。 And in case you have an error log, consult that, it will help you trace the problem quickly. 并且如果您有错误日志,请查阅该日志,这将帮助您快速查找问题。

When i have this problem, it's usually a notice or a warning showing up during the process of the image generation, and if you haven't disabled errors from being output to the screen, the notice text will be considered as part of the image data which makes the browser unable to interpret your image. 当我遇到此问题时,通常是在图像生成过程中出现的通知或警告,并且如果您尚未禁用将错误输出到屏幕的信息,则通知文本将被视为图像数据的一部分这使浏览器无法解释您的图像。

If you'd like i can take a look closely for you but i would need to see what you are doing in that php file to be able to tell you for sure. 如果您愿意,我可以为您仔细看一下,但是我需要查看您在该php文件中正在做什么,以便可以肯定地告诉您。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM