Jump to content

Recommended Posts

I assume you mean 'if file exists, overwrite?'..  You could store the temporary file name ($_FILES['tmp_name']) within a session variable, prompt the user, then if they agree "move_uploaded_file". Would it not be better to use a system where you don't get duplicate file names though?

Link to comment
https://forums.phpfreaks.com/topic/184776-uploading-with-php/#findComment-975463
Share on other sites

The temp uploaded file is actually deleted automatically when the script on the page that is the target of the form finishes execution, so you would actually need to store the whole temp uploaded file somewhere and a session variable is about the best place if you want it to be automatically deleted once you are finished with it.

Link to comment
https://forums.phpfreaks.com/topic/184776-uploading-with-php/#findComment-975466
Share on other sites

Actually just found out the file is deleted at the end of the request. In that case then you could move the file to another location, temporarily, while you prompt the user to overwrite the original. Or .. Something as simple as a check box actually as they upload the file could be easier.

 

Edit: Heh,  PFMaBiSmAd beat me to it.

Link to comment
https://forums.phpfreaks.com/topic/184776-uploading-with-php/#findComment-975468
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.