开发者

display image from file in temp uploaded directory

How can I display an image from file object? The file object holds the 开发者_如何学Clocation of the image in temp uploaded directory.

I dont want to use any models.

Its for previewing a form having filefield


The problem with most temporary files is that they don't exist. They're in a deleted state and will disappear entirely once the file handle is closed. It's your responsibility to move copy the data out of them and into another file, database, or cache, whatever works best, in order to preserve it.

You don't need to use any models to make this work, but you will need to be able to write to a directory your web server will be able to access. Typically you can make a /uploads directory and copy the file there, removing it later on when it is no longer required.

That clean-up step is easily done by a cron job that deletes all files with an mtime of a day or so, depending on your preference.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜