2011-02-24 73 views
0

對此不熟悉,但已經是我的頭腦了。 Vids沒有上傳/正在創建,但沒有錯誤消息,並且文件名/目錄位置也被記錄到MySQL中。視頻上傳腳本不能正常工作

HUH ?!

下面的代碼:


<?php 

date_default_timezone_set("America/New_York"); 
include("functionpage.php"); 
session_start(); 

if (isset($_SESSION['firstname'])) 
{ 

if (isset($_POST["submit"]) && $_FILES["uploadfile"]["name"] != "") 
{                


    if (!$connect = mysqli_connect($lh, $rt, $pw, $gj)) 
    {  
     echo "<p>We're sorry, but the connection to the server is currently unavailable. <br /> Thank you for your patience.<br /><br /> 
     exit(); 
    } 

    $namefirst = $_SESSION['firstname']; 

    echo $namefirst."<br /><br />"; 

    $sql = "SELECT * FROM cust_vids WHERE firstname = '$namefirst'"; 

    $result = mysqli_query($connect,$sql); 

    if (mysqli_num_rows($result) > 0) 
    { 
      $rows = mysqli_fetch_assoc($result); 
      extract($rows); 

      $directory = "videos/".$username."/".$namefirst; 

      if(!is_dir($directory)) 
      { 
        mkdir($directory); 
      } 

      $uploadfile = mysqli_real_escape_string($connect,$_FILES["uploadfile"]["name"]); 
      $uploadfile = strtolower(trim($uploadfile)); 
      $vidtype = $_FILES["uploadfile"]["type"]; 
      $vidsize = $_FILES["uploadfile"]["size"]/1024; 
      $vidtmp = $_FILES["uploadfile"]["tmp_name"]; 
      include("layout.php"); 
      echo "Upload: " . $uploadfile . "<br />"; 
      echo "Type: " . $vidtype . "<br />"; 
      echo "Size: " . $vidsize . " Kb<br />"; 
      echo "Stored in: " . $vidtmp."<br /><br />"; 
      echo $username."<br />"; 
      echo $firstname."<br />"; 
      echo $namefirst."<br />"; 

      $extension = explode(".",$uploadfile); 
      $ext = $extension[1]; 
      $permloc = $directory.$uploadfile; 

      echo "<p>".$ext."<br />"; 

      /*Will check to see if the file has an extension that isn't allowed*/ 
      if ($ext != "swf" && $ext != "mov" && $ext != "wmv" && $ext != "avi" && $ext != "mpg" && $ext != "mpeg" 
       && $ext != "mp4" && $ext != "flv") 
      { 
       echo "<p>We're sorry, but we do not support this type of file. <br /> 
       Thank you for your patience.<br /><br /> 
       <a href=\"uploadvid.php\">Back to upload video form</a><br /> 
       exit(); 
      } 


      if (file_exists($permloc)) 
      { 
        echo "<p>File already exists.<br /><br /> 
        <a href=\"blog.php\">Back to Main Blog Page</a>.</p>"; 
        exit(); 
      } 
      else 
      { 
        move_uploaded_file($vidtmp,$permloc); 
        echo "<br />New location: ".$permloc."<br /><br />"; 
        $sql2 = "INSERT INTO cust_vids (username, firstname, uploadvids,videolocation) 
        VALUES (\"$username\",\"$firstname\", \"$uploadfile\", \"$permloc\")"; 

        $result2 = mysqli_query($connect,$sql2); 
        if (!$result2) 
        { 
         echo "<p>Sorry, but your file was not uploaded into our records. Please try again.<br /><br /> 
         <a href=\"uploadvid.php\">Back to upload video form</a><br /> 
         <a href=\"blog.php\">Back to Main Blog Page</a>.</p>"; 
         exit(); 
        } 
        else 
        { 
         echo "<p>The file has been uploaded into your account successfully.<br /><br /> 
         Back to <a href=\"Blog.php\">Main Blog Page</a></p>"; 
         exit(); 
        } 
      } 
    } 
    else 
    { 
     include("layout.php"); 
     echo "<p>We're sorry, but there is no user account under that username. Please try again. <br /><br /> 
     <a href=\"uploadvid.php\">Back to upload video form</a><br /> 
     <a href=\"blog.php\">Back to Main Blog Page</a>.</p>"; 
     exit(); 
    } 
} 
} 
else 
{ 
    header("location:blog.php"); 
} 

?> 



<html> 
<head> 
<title>Test script</title> 
</head> 

<body> 
    <?php include("layout.php"); ?> 

    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" enctype="multipart/form-data"> 
    <input type="hidden" name="MAXFILESIZE" value="2147483648" /><!--Equals to around 28 mb--> 
    ADD SCENE: 
    <input type="file" name='uploadfile' size="30" maxlength="100"/><br /> 
    <input type= "submit" name="submit" value="UPLOAD"/> 
    </form> 
</body> 
</html> 

/文件結束/


任何幫助/洞察力,將不勝感激。謝謝!

+0

-1在任何人打算幫助你之前,你需要做更多的工作調試。 – 2011-02-24 06:25:52

+0

嘗試最簡單的腳本,看看你的系統/ form/php是否可以真正上傳,並開始上傳小文件。然後一路走到視頻。不要編寫大量的代碼並在稍後測試,您可以逐個測試它。 – 2011-02-26 14:39:45

回答

1

這可能是您的服務器對您的服務器有一個size_limit,並且您必須將其設置爲您的php上傳腳本的設置。

0

檢查「file_uploads」是否設置爲「On」,「upload_max_filesize」是否足夠。