How can I display an image from file object? The file object holds the location of the image in temp uploaded directory.
I dont want to use any models.
Its for previewing a form having filefield
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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
/uploadsdirectory 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.