Viewed   84 times

I am working on an upload script.

If a user uploads a file and it already exists I want to warn the user (this is all through ajax) and give them the option to replace it, or cancel.

Instead of moving the file, I was curious if I could just leave the file in tmp and pass back the path to that file in the ajax response.

If they user says overwrite the old file in that ajax request pass the path back to php which continues to work on the file.

For this to work however I need to know how long a file stays in php's tmp dir



Files uploaded through POST are deleted right after php script finishes its execution.

According to "The file will be deleted from the temporary directory at the end of the request if it has not been moved away or renamed."

Tuesday, December 20, 2022

You're just passing the last line to html2text , and you are not using html2text correctly do this instead :

import html2text
import sys

print html2text.html2text(
Sunday, August 28, 2022

Check this :

In particular, it is stated:

The server timed out and closed the connection. By default, the server closes the connection after 8 hours or 28800 seconds if nothing has happened. You can change the time limit by setting the wait_timeout variable when you start mysqld via your server’s /etc/my.cnf [...]

Monday, August 29, 2022

Not the answer you're looking for - but I can definitively say that there's no configuration option to change where Rails thinks the tmp folder is. The location is hard coded in many different places in the Rails codebase.

Looks like the symlink will sync the original file, so you'll probably have the same locking problems.

If you do, then you can just use the symlinks the other way around to solve your problem, ie. create your project outside your dropbox, and symlink everything other than tmp into a folder in your dropbox.

So you might have your Rails app in ~/work/rails_project/<all the rails dirs including tmp> and then you'll have a corresponding dir in your dropbox, like ~/dropbox/rails_project and then inside that dir you'll manually create a bunch of symlinks and then delete the tmp one, using bash you'd do this:

$ for f in ~/work/rails_project/*; do ln -s $f; done
$ rm tmp

You'd need to remember to run that again if you ever added a new file/directory to the root of your app.

Friday, November 11, 2022

TMP, TEMP (and maybe TMPDIR) are valid on Windows only and usually pointing to C:WindowsTEMP. On Linux default temp location is /tmp. To workaround this (works with tempnam() function) you can create a temp folder somewhere within your website space, specify appropriate access permissions and pass this as first parameter to the above function.

Not a great solution but better than nothing.

Tuesday, December 27, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :