J-C Posted March 14, 2010 Share Posted March 14, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/195163-upload-only-if-submit-has-been-clicked/ Share on other sites More sharing options...
teamatomic Posted March 14, 2010 Share Posted March 14, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/195163-upload-only-if-submit-has-been-clicked/#findComment-1025796 Share on other sites More sharing options...
J-C Posted March 14, 2010 Author Share Posted March 14, 2010 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> Quote Link to comment https://forums.phpfreaks.com/topic/195163-upload-only-if-submit-has-been-clicked/#findComment-1025803 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.