开发者

redirect to a new page once file upload is finished

I have got the following php file for my file upload, how do I redirect to a new page once the file is finished upload, thanks in advance.

<?php
echo <<<_END
<html>

<title>PHP Form Upload</title开发者_运维知识库></head><body>
<form method = 'post' action='testupload.php' enctype='multipart/form-data'>
Select File: <input type='file' name='filename' size='10' />
<input type='submit' value='Upload' />
</form>


_END;


 if($_FILES)
{
$a = uniqid();
   $saveto =  $a.".jpg";;
 // $name = $_FILES['filename']['name'];
  move_uploaded_file($_FILES['filename']['tmp_name'],  $saveto);
  $typeok = TRUE;

  switch($_FILES['filename']['type'])
   {
     case "image/gif": $src = imagecreatefromgif($saveto); break;

       case "image/jpeg":
         case "image/pjpeg":  $src = imagecreatefromjpeg($saveto); break;

      case "image/png": $src = imagecreatefrompng($saveto); break;

       default: $typeok = FALSE; break;
    }


     echo "Upload image '$saveto'<br/><img src='$saveto' />";
  }
  if ($_FILES["filename"]["size"] > 2000)
     {
      echo "Error: file is too big" . $_FILES["file"]["error"] . "<br />";
     }

  echo"</body></html>";

   ?>    


Perform the redirection as normal in your action, i.e. testupload.php.


put your if statement for _FILES before everything, and when upload is finished (move_uploaded_file probably), put this code

header("Location: newlocation.php");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜