Clearing echo text on page refresh
I am designing an image file upload page for a website and, on Submit, the script echoes an 'Upload Successful' message. That all works fine.
My problem is that once the success me开发者_运维知识库ssage is on the page, it won't go away! If the user wants to upload another file, I want him to be able to refresh the page and get rid of the echoed message. I can't understand why that doesn't happen by default but can anyone explain how I make that happen?
Mike
2 ways I can think of doing what you want.
First, put a link back to the upload script underneath your upload successful text.
echo '<h3>Upload Successful</h3>';
echo '<a href="upload_script.php">Upload another file</a>';
The second way involves sending a refresh header which will redirect to the upload page after a few seconds.
header( "refresh:3;url=upload_script.php" );
echo '<h3>Upload Successful</h3>';
This will redirect to the upload page after 3 seconds. header() must be called before your script outputs (echo) anything to the page.
精彩评论