开发者

PIL changes file name while saving

When I use the save method in PIL to save a file, it saves it by the right file name I provide, but on 开发者_StackOverflow社区clicking on the file name the path shows to be different. (Sorry, my explanation sucks).

For example, if u go to http://shopperspoll.webfactional.com/media/images/emailTemplate/mergedImages/ there is an image named "7962716_41tlK2uT%2BSL.SL75.png". On clicking on the image though, the name of the file that shows up on the browser changes to "7962716_41tlK2uT%252BSL.SL75.png" with the additional "52" in the file name. I am using image.save(pathName) to save the image.

Thanks!


As 7962716_41tlK2uT%2BSL.SL75.png is a valid filename, it is saved on your filesystem. The browser urlencodes the filename, so 7962716_41tlK2uT%2BSL.SL75.png becomes 7962716_41tlK2uT%252BSL.SL75.png; the percent sign in your filename becomes %25.

So PIL does not change your filename, your browser escapes your actual filename. That's all!

Given a query with the parameter q, you get:

>>>urllib.urlencode({'q':'7962716_41tlK2uT%2BSL.SL75.png'}) == "q=7962716_41tlK2uT%252BSL.SL75.png"
True
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜