Store file temporarily on a web page

I need to set up a page that will allow the user to upload the file, modify the file using a script, and then transfer the file back to the user.

I have loading and changing parts down, but I don’t know where to put the file. They will be located in the region of 1 or 2 MB, and I have very little space on my web hosting plan, so I want to get rid of the files as soon as possible. There is no reason for the files to exist longer than after users were given the opportunity to download their browser when redirecting.

Is this the only way to do this with a cron job that checks the creation time of files and deletes them if they are of a certain age?

I work with python and PHP.

edit:

First the file is uploaded. Then the file location is sent back to the user. Javascript on the page redirects the file path. The browser opens a file save dialog, and they prefer to save the file or cancel it. If they are canceled, I want to delete the file immediately. If they want to save the file, I want to delete the file after the download is complete.

+3
source share
3 answers

I don’t know why I didn’t think about it, but I was at the IRC for Python discussing a completely unrelated issue, and someone asked why I wasn’t just serving the file. Exactly!

I never needed to save the file, just to send it back to the user with the correct header. The problem is solved!

0
source

, . for any uploaded file, the life time is 5 mins.

Kniganapolke , , . , ( , ), .

, .

. . Cron - , , FireFox. javascript, , Firefox? , , javascript. , . script . Python? , cron.

- , . , ( ), (, 5 ), , .

, Celery ( )

-, , , URL-. , (, 1 )? (, apache nginx), , - , . -, .

-. .

http://bitkickers.blogspot.com/2010/07/djangocelery-quickstart-or-how-i.html

python

+1

, - - JavaScript AJAX script, .
, ( IE onBeforeUnload).

: , . . JavaScript.

0
source

All Articles