Jump to content

phreak3r

Members
  • Content Count

    97
  • Joined

  • Last visited

Community Reputation

1 Neutral

About phreak3r

  • Rank
    Regular Member

Recent Profile Visitors

223 profile views
  1. phreak3r

    POST error upon uploading a file

    An example? Please and thank you!
  2. phreak3r

    POST error upon uploading a file

    Sarcastic and cynical. Mmmm...my favorite flavor! What is the difference between my canned messages and using an array to 'save' generated messages? I am the kind of person that needs things further simplified sometimes.
  3. phreak3r

    POST error upon uploading a file

    So it is not the same as my array holding defined error messages? I might have an idea of what you mean, but for the most part I do not. How would this help? In my mind, PHP is a language where you are simply manipulating arrays, that's all. At least that is how I interpret it.
  4. phreak3r

    POST error upon uploading a file

    mac_gyver, that worked, I am still getting an error, but at least there isn't any of the null business.
  5. phreak3r

    POST error upon uploading a file

    The Loaded Configuration File is /etc/php/7.2/apache2/php.ini. Both master and local are 8M. I modified the drb@z10n:/etc/php/7.2/cli path. 😕
  6. phreak3r

    POST error upon uploading a file

    ginerjm, I think the form is valid. I will scour the Internet for some similar problems.
  7. phreak3r

    POST error upon uploading a file

    Yes, it does. I made a simple mistake and added a semicolon after the variable. For example : echo $a; "<br>";
  8. phreak3r

    POST error upon uploading a file

    Okay, well I tried using "." but that did not really seem to work. Thank you for your contribution. I know many of my previous posts may display the behavior "IT'S BROKEN! HELP!", but I am genuinely trying to understand this all.
  9. phreak3r

    POST error upon uploading a file

    Apparently there is nothing in the array. Array ( ) And why is a comma used instead of a period in reference to the echo "<pre>",print_r($_POST, true),"</pre>"; line?
  10. phreak3r

    POST error upon uploading a file

    If you really want to see the whole code, here it goes. I could do with some better erm...organization/structure? It is such a big script, so I tried to refrain from including it. <?php include('header.php'); require('dbcon/dbcon.php'); include('functions.php'); isLoggedIn(); if ($_SERVER['REQUEST_METHOD'] == 'POST') { // Error declaration $error = ["Your file is too big!", "There was an error uploading your file!", "Cannot upload file of this type!", "Empty fields!"]; // Process POST variables $videoTitle = $_POST['video_title']; $videoDesc = $_POST['textarea-videoDesc']; // Process session variable $username = $_SESSION['username']; // file upload stuff... $file = $_FILES['videoFile']; $fileName = $file['name']; $fileTmpName = $file['tmp_name']; $fileSize = $file['size']; $fileError = $file['error']; $fileType = $file['type']; $fileExt = explode('.', $fileName); $fileActualExt = strtolower(end($fileExt)); $allowed = array('mp4', 'mov', 'mkv'); if (in_array($fileActualExt, $allowed)) { if ($fileError === 0) { if ($fileSize < 2000000) { $fileNameNew = $username . "." . $fileActualExt; $fileDestination = "channel/" . $username . "/videos/" . $fileNameNew; move_uploaded_file($fileTmpName, $fileDestination); } else { echo $error[0]; } } else { echo $error[1]; } } else if (!$allowed) { echo $error[2]; } //////////////////////////////////////////////////////////////////// $thumbnailImageFile = $_FILES['thumbnailImage']; $thumbnailImageName = $_FILES['thumbnailImage']['name']; $thumbnailImageTmpName = $_FILES['thumbnailImage']['tmp_name']; $thumbnailImageSize = $_FILES['thumbnailImage']['size']; $thumbnailImageError = $_FILES['thumbnailImage']['error']; $thumbnailImageType = $_FILES['thumbnailImage']['type']; $thumbnailImageExt = explode('.', $thumbnailImageName); $thumbnailImageActualExt = strtolower(end($thumbnailImageExt)); $allowedThumbnailFileExts = array('png', 'jpg', 'jpeg'); if (in_array($thumbnailImageActualExt, $allowedThumbnailFileExts)) { if ($thumbnailImageError === 0) { if ($thumbnailImageSize < 200000000) { $thumbnailImageNameNew = $username . "thumbnailImage" . uniqid('', true). "." . $thumbnailImageActualExt; $thumbnailImageDestination = 'uploads/thumbnails/' . $thumbnailImageNameNew; move_uploaded_file($thumbnailImageTmpName, $thumbnailImageDestination); } else { echo $error[0]; } } else { echo $error[1]; } } else if (!$allowed) { echo $error[2]; } if (isset($file) && $fileSize != 0 /*&& $thumbnailImageSize != 0*/ && !empty($videoTitle)) { $sql = $pdo->prepare("INSERT into videos001 (uploader, video, thumbnail, video_title, video_desc) VALUES (:username, :fileDestination, :thumbnailImageDestination, :videoTitle, :videoDesc)"); $sql->bindValue(':username', $username); $sql->bindValue(':fileDestination', $fileDestination); $sql->bindValue(':thumbnailImageDestination', $thumbnailImageDestination); $sql->bindValue(':videoTitle', $videoTitle); $sql->bindValue(':videoDesc', $videoDesc); $sql->execute(); header('Location: /soapbox/upload.php?success'); } else { echo $error[3]; var_dump($file, $videoTitle, $videoDesc); } } // end of if server method... // TODO: if there's no thumbnail, do not upload video, let user know to put in a thumbnail ?> <!DOCTYPE html> <html> <head> <title>soapbox - upload</title> </head> <body> <form action="upload.php" method="POST" enctype="multipart/form-data" multiple><br> <p>Video File:</p><input type="file" name="videoFile" id="fileToUpload"><br> <p>Thumbnail Image File: </p><input type="file" name="thumbnailImage"><br> <p>Video Title: </p><input type="text" name="video_title" id="videoTitle" placeholder="Video title"><br> <p>Video Description</p><textarea name="textarea-videoDesc" placeholder="Video description..." rows="7" style="resize: none;"></textarea><br> <br><input type="submit" name="uploadBtn" value="Upload"> </form> </body> </html>
  11. phreak3r

    POST error upon uploading a file

    I restarted the Apache2 service. Oh! I am so sorry, I forgot to add in the script, here you go. if (isset($file) && $fileSize != 0 /*&& $thumbnailImageSize != 0*/ && !empty($videoTitle)) { $sql = $pdo->prepare("INSERT into videos001 (uploader, video, thumbnail, video_title, video_desc) VALUES (:username, :fileDestination, :thumbnailImageDestination, :videoTitle, :videoDesc)"); $sql->bindValue(':username', $username); $sql->bindValue(':fileDestination', $fileDestination); $sql->bindValue(':thumbnailImageDestination', $thumbnailImageDestination); $sql->bindValue(':videoTitle', $videoTitle); $sql->bindValue(':videoDesc', $videoDesc); $sql->execute(); header('Location: /soapbox/upload.php?success'); } else { echo $error[3]; var_dump($file, $videoTitle, $videoDesc); }
  12. I am working on a video-hosting site, something akin to YouTube. I converted whatever MySQLi I had to PDO. This piece of particular code is responsible for checking if the fields are filled in; then proceeds to upload the files and inserts data into the database. The code jumps straight to the error I created which is "empty fields". The var_dump prints out as null all the way. I cannot seem to figure out where the problem lies. I would say it could be that the file is not set? I am not quite sure. Here is what the log gives me: [Sat Feb 16 00:19:35.575770 2019] [php7:warn] [pid 16239] [client 127.0.0.1:42504] PHP Warning: POST Content-Length of 12263648 bytes exceeds the limit of 8388608 bytes in Unknown on line 0, referer: http://localhost/soapbox/upload.php [Sat Feb 16 00:19:35.576769 2019] [php7:notice] [pid 16239] [client 127.0.0.1:42504] PHP Notice: Undefined index: video_title in /var/www/html/soapbox/upload.php on line 15, referer: http://localhost/soapbox/upload.php [Sat Feb 16 00:19:35.576805 2019] [php7:notice] [pid 16239] [client 127.0.0.1:42504] PHP Notice: Undefined index: textarea-videoDesc in /var/www/html/soapbox/upload.php on line 16, referer: http://localhost/soapbox/upload.php [Sat Feb 16 00:19:35.576811 2019] [php7:notice] [pid 16239] [client 127.0.0.1:42504] PHP Notice: Undefined index: videoFile in /var/www/html/soapbox/upload.php on line 22, referer: http://localhost/soapbox/upload.php [Sat Feb 16 00:19:35.576829 2019] [php7:notice] [pid 16239] [client 127.0.0.1:42504] PHP Notice: Undefined index: thumbnailImage in /var/www/html/soapbox/upload.php on line 51, referer: http://localhost/soapbox/upload.php [Sat Feb 16 00:19:35.576845 2019] [php7:notice] [pid 16239] [client 127.0.0.1:42504] PHP Notice: Undefined index: thumbnailImage in /var/www/html/soapbox/upload.php on line 52, referer: http://localhost/soapbox/upload.php [Sat Feb 16 00:19:35.576849 2019] [php7:notice] [pid 16239] [client 127.0.0.1:42504] PHP Notice: Undefined index: thumbnailImage in /var/www/html/soapbox/upload.php on line 53, referer: http://localhost/soapbox/upload.php [Sat Feb 16 00:19:35.576854 2019] [php7:notice] [pid 16239] [client 127.0.0.1:42504] PHP Notice: Undefined index: thumbnailImage in /var/www/html/soapbox/upload.php on line 54, referer: http://localhost/soapbox/upload.php [Sat Feb 16 00:19:35.576858 2019] [php7:notice] [pid 16239] [client 127.0.0.1:42504] PHP Notice: Undefined index: thumbnailImage in /var/www/html/soapbox/upload.php on line 55, referer: http://localhost/soapbox/upload.php [Sat Feb 16 00:19:35.576862 2019] [php7:notice] [pid 16239] [client 127.0.0.1:42504] PHP Notice: Undefined index: thumbnailImage in /var/www/html/soapbox/upload.php on line 56, referer: http://localhost/soapbox/upload.php I have changed the allotted sizes in the php.ini file, so that rules out the POST Content-Length problem, I think. Here are the "undefined indexes": $videoTitle = $_POST['video_title']; $videoDesc = $_POST['textarea-videoDesc']; $file = $_FILES['videoFile']; $thumbnailImageName = $_FILES['thumbnailImage']['name']; $thumbnailImageTmpName = $_FILES['thumbnailImage']['tmp_name']; $thumbnailImageSize = $_FILES['thumbnailImage']['size']; $thumbnailImageError = $_FILES['thumbnailImage']['error']; $thumbnailImageType = $_FILES['thumbnailImage']['type']; $thumbnailImageExt = explode('.', $thumbnailImageName); And the corresponding form names to go with them: <form action="upload.php" method="POST" enctype="multipart/form-data" multiple><br> <p>Video File:</p><input type="file" name="videoFile" id="fileToUpload"><br> <p>Thumbnail Image File: </p><input type="file" name="thumbnailImage"><br> <p>Video Title: </p><input type="text" name="video_title" id="videoTitle" placeholder="Video title"><br> <p>Video Description</p><textarea name="textarea-videoDesc" placeholder="Video description..." rows="7" style="resize: none;"></textarea><br> <br><input type="submit" name="uploadBtn" value="Upload"> </form>
  13. phreak3r

    $row['index here'] outputs null

    Okay, thank you.
  14. phreak3r

    $row['index here'] outputs null

    Yes, however, that was not really the issue. Not sure if this is the solution I am looking for, but I changed $row == 1 && password_verify($password, $row['password']) to $row['username'] == $username && password_verify($password, $row['password']. But, thank you.
  15. phreak3r

    $row['index here'] outputs null

    Right, right. Sorry. 😬
×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.