表单操作dropzonejs后的php重定向

时间:2013-05-12 19:17:11

标签: php redirect

您好我在index.php中有以下表格

  <form action="file1.php?arg=<?php echo $id ?>"
    class="dropzone"
    id="my-awesome-dropzone">
  </form>

同样在index.php我有

  if ( !isset($_SESSION['logged-in']) || $_SESSION['logged-in'] !== true) {
    header('Location: file.php');
    exit;
  }

file1.php如下

  $ds = DIRECTORY_SEPARATOR;  //1
  $storeFolder = 'dir'.$id;   //2
  if (!empty($_FILES)) {
    $tempFile = $_FILES['file']['tmp_name'];          //3              
    $targetPath = dirname( __FILE__ ) . $ds. $storeFolder . $ds;  //4
    $targetFile =  $targetPath. $_FILES['file']['name'];  //5
    move_uploaded_file($tempFile,$targetFile); //6
  }

如何在move_uploaded_file完成后重定向到mytest.php文件?

提前谢谢

1 个答案:

答案 0 :(得分:0)

$ds = DIRECTORY_SEPARATOR;  //1
$storeFolder = 'dir'.$id;   //2

if (!empty($_FILES)) {
    $tempFile = $_FILES['file']['tmp_name'];          //3              
    $targetPath = dirname( __FILE__ ) . $ds. $storeFolder . $ds;  //4
    $targetFile =  $targetPath. $_FILES['file']['name'];  //5
    $status = move_uploaded_file($tempFile,$targetFile); //6

    if($status){ // If it return's true on SUCCESS
        header('Location: mytest.php');
        exit;
    }

}