Upload PHP code - go to ThankYou page after upload complete?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
greenink
Forum Newbie
Posts: 2
Joined: Tue May 15, 2007 3:37 pm

Upload PHP code - go to ThankYou page after upload complete?

Post by greenink »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


How do I get this code to re-direct me back to the page I was on or take me to a Thank you page maybe...an html page with the site's template so that the user can go back to the site easily after they've uploaded....

Code: Select all

<?php
    $target = "/home/content/l/y/n/lynclair/html/Test/uploads/";
    $target = $target . basename( $_FILES['uploaded']['name']) ;
    $ok=1;

    //This is our size condition
    if ($uploaded_size > 5000000)
    {
    echo "Your file is too large.<br>";
    $ok=0;
    }

    //This is our limit file type condition
    if ($uploaded_type =="text/php")
    {
    echo "No PHP files<br>";
    $ok=0;
    }

    //Here we check that $ok was not set to 0 by an error
    if ($ok==0)
    {
    Echo "Sorry your file was not uploaded";
    }

    //If everything is ok we try to upload it
    else
    {
    if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
    {
    echo "The file ".

    basename( $_FILES['uploadedfile']['name']). " has been uploaded";
    }
    else
    {
    echo "Sorry, there was a problem uploading your file.";
    }
    }
    ?>
Thanks for the help to whomever answers... :)


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
guitarlvr
Forum Contributor
Posts: 245
Joined: Wed Mar 21, 2007 10:35 pm

Post by guitarlvr »

try header(). You will want to pay particularly close attention to header(location: $var);

Wayne
Post Reply