Jump to content


Photo

Very quick question


  • Please log in to reply
3 replies to this topic

#1 Gruzin

Gruzin
  • Members
  • PipPipPip
  • Advanced Member
  • 448 posts
  • LocationGeorgia

Posted 08 September 2006 - 03:39 PM

Hi guys, hope you are doing well!
I need to pause and show some echo to the user before redirect. I'am using sleep, but think something's wrond. Thank you very much for your help.

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
    echo "The file ".  basename( $_FILES['uploadedfile']['name']).
    " has been uploaded";
sleep(3); // wait 3 seconds and then redirect
header ('Location: index.php');
} else{
    echo "There was an error uploading the file, please try again!";
}


I don't need your script, I'll try to write it myself

#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 08 September 2006 - 03:41 PM

The problem's going to be that once you output something to the browser ( ... has been uploaded), the header function will error out.  If you want to display something as a success message, then just replace the header() call with a simple href link to index.php
Legend has it that reading the manual never killed anyone.
My site

#3 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 08 September 2006 - 03:42 PM

Use header redirect instead:
header("Refresh: 3; URL=index.php");
echo "The file " . basename( $_FILES['uploadedfile']['name']) . " has been uploaded";

instead of

echo "The file " . basename( $_FILES['uploadedfile']['name']) . " has been uploaded";
sleep(3); // wait 3 seconds and then redirect
header ('Location: index.php');

That will redirect the user back to index.php after three secounds has passed.



#4 Gruzin

Gruzin
  • Members
  • PipPipPip
  • Advanced Member
  • 448 posts
  • LocationGeorgia

Posted 08 September 2006 - 03:48 PM

It works, thank u very much  :)
I don't need your script, I'll try to write it myself




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users