Jump to content

Upload only if submit has been clicked


J-C

Recommended Posts

Ok my main problem is that When I refresh a page ( upload.php ) it uploads the file even if the form has not been submitted through the upload page ( index.php ), so essentially what I want is that when I refresh the page where I uploaded the file, instead of re-uploading to just keep the last uploaded file instead.

 

Would this be achieved through sessions? if so can anyone help me please, because is really annoying that it just keeps re-uploading when I press refresh.

Link to comment
Share on other sites

Sounds like this is the logic you need.

session_start();
if (isset($_SESSION['key']))
{
echo "FILE ALREADY SENT";
      exit;
}
if(isset($_POST['submit']))
{
$_SESSION['key']=$_POST['key'];

}
echo "{$_POST['tester']}";
?>
<form method=post action=''>
<input type='hidden' name='key' value='AvR5G6dS34'/>
<input type='text' name='tester' value=''/>
<br>
<input type='submit' name='submit' value='submit'/>
</form>

 

 

HTH

Teamatomic

Link to comment
Share on other sites

Is it supposed to be in the same file? because the form is in index.php and the upload script is in upload.php, this is the form:

 

<form action="upload.php" method="POST" enctype="multipart/form-data" 
name="upform" onSubmit="return No_file();">
<div class="input"> 
Image to upload: <br /> 
<input type="file" name="upload" />
<br /> 
</div>
<center> <input type=submit name=Submit value="Upload Image" /> </center>
</form>

Link to comment
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.