Note that there are some explanatory texts on larger screens.

plurals
  1. POVideo upload script not working
    text
    copied!<p>New to this, but already I'm scratching my head. Vids aren't uploading/being created, but there's no error msg, and also the filenames/directory location's being recorded into MySQL.</p> <p>HUH?!</p> <p>Here's the code:</p> <hr> <pre><code>&lt;?php date_default_timezone_set("America/New_York"); include("functionpage.php"); session_start(); if (isset($_SESSION['firstname'])) { if (isset($_POST["submit"]) &amp;&amp; $_FILES["uploadfile"]["name"] != "") { if (!$connect = mysqli_connect($lh, $rt, $pw, $gj)) { echo "&lt;p&gt;We're sorry, but the connection to the server is currently unavailable. &lt;br /&gt; Thank you for your patience.&lt;br /&gt;&lt;br /&gt; exit(); } $namefirst = $_SESSION['firstname']; echo $namefirst."&lt;br /&gt;&lt;br /&gt;"; $sql = "SELECT * FROM cust_vids WHERE firstname = '$namefirst'"; $result = mysqli_query($connect,$sql); if (mysqli_num_rows($result) &gt; 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 . "&lt;br /&gt;"; echo "Type: " . $vidtype . "&lt;br /&gt;"; echo "Size: " . $vidsize . " Kb&lt;br /&gt;"; echo "Stored in: " . $vidtmp."&lt;br /&gt;&lt;br /&gt;"; echo $username."&lt;br /&gt;"; echo $firstname."&lt;br /&gt;"; echo $namefirst."&lt;br /&gt;"; $extension = explode(".",$uploadfile); $ext = $extension[1]; $permloc = $directory.$uploadfile; echo "&lt;p&gt;".$ext."&lt;br /&gt;"; /*Will check to see if the file has an extension that isn't allowed*/ if ($ext != "swf" &amp;&amp; $ext != "mov" &amp;&amp; $ext != "wmv" &amp;&amp; $ext != "avi" &amp;&amp; $ext != "mpg" &amp;&amp; $ext != "mpeg" &amp;&amp; $ext != "mp4" &amp;&amp; $ext != "flv") { echo "&lt;p&gt;We're sorry, but we do not support this type of file. &lt;br /&gt; Thank you for your patience.&lt;br /&gt;&lt;br /&gt; &lt;a href=\"uploadvid.php\"&gt;Back to upload video form&lt;/a&gt;&lt;br /&gt; exit(); } if (file_exists($permloc)) { echo "&lt;p&gt;File already exists.&lt;br /&gt;&lt;br /&gt; &lt;a href=\"blog.php\"&gt;Back to Main Blog Page&lt;/a&gt;.&lt;/p&gt;"; exit(); } else { move_uploaded_file($vidtmp,$permloc); echo "&lt;br /&gt;New location: ".$permloc."&lt;br /&gt;&lt;br /&gt;"; $sql2 = "INSERT INTO cust_vids (username, firstname, uploadvids,videolocation) VALUES (\"$username\",\"$firstname\", \"$uploadfile\", \"$permloc\")"; $result2 = mysqli_query($connect,$sql2); if (!$result2) { echo "&lt;p&gt;Sorry, but your file was not uploaded into our records. Please try again.&lt;br /&gt;&lt;br /&gt; &lt;a href=\"uploadvid.php\"&gt;Back to upload video form&lt;/a&gt;&lt;br /&gt; &lt;a href=\"blog.php\"&gt;Back to Main Blog Page&lt;/a&gt;.&lt;/p&gt;"; exit(); } else { echo "&lt;p&gt;The file has been uploaded into your account successfully.&lt;br /&gt;&lt;br /&gt; Back to &lt;a href=\"Blog.php\"&gt;Main Blog Page&lt;/a&gt;&lt;/p&gt;"; exit(); } } } else { include("layout.php"); echo "&lt;p&gt;We're sorry, but there is no user account under that username. Please try again. &lt;br /&gt;&lt;br /&gt; &lt;a href=\"uploadvid.php\"&gt;Back to upload video form&lt;/a&gt;&lt;br /&gt; &lt;a href=\"blog.php\"&gt;Back to Main Blog Page&lt;/a&gt;.&lt;/p&gt;"; exit(); } } } else { header("location:blog.php"); } ?&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Test script&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;?php include("layout.php"); ?&gt; &lt;form action="&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;" method="POST" enctype="multipart/form-data"&gt; &lt;input type="hidden" name="MAXFILESIZE" value="2147483648" /&gt;&lt;!--Equals to around 28 mb--&gt; ADD SCENE: &lt;input type="file" name='uploadfile' size="30" maxlength="100"/&gt;&lt;br /&gt; &lt;input type= "submit" name="submit" value="UPLOAD"/&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>/<em>End of file</em>/</p> <hr> <p>Any help/insight would be appreciated. Thx!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload