I’m using this php script that uploads videos.
In the browser it shows …/uploader.php
and on the page is shows
But I can’t find the code for that, in the uploader.php file (attached).
If you took take a peek at the attached file, and help me figure out where that code is for the “Choose File” & “Upload”, I’d greatly appreciate it. (Yes, I know this is an old script). Thanks.
<?php
// Access the $_FILES global variable for this specific file being uploaded
// and create local PHP variables from the $_FILES array of information
$fileName = $_FILES["uploaded_file"]["name"]; // The file name
$fileTmpLoc = $_FILES["uploaded_file"]["tmp_name"]; // File in the PHP tmp folder
$fileType = $_FILES["uploaded_file"]["type"]; // The type of file it is
$fileSize = $_FILES["uploaded_file"]["size"]; // File size in bytes
$fileErrorMsg = $_FILES["uploaded_file"]["error"]; // 0 for false... and 1 for true
$fileName = preg_replace('#[^a-z.0-9]#i', '', $fileName); // filter the $filename
$kaboom = explode(".", $fileName); // Split file name into an array using the dot
$fileExt = end($kaboom); // Now target the last array element to get the file extension
// START PHP Image Upload Error Handling --------------------------------
if (!$fileTmpLoc) { // if file not chosen
echo "ERROR: Please browse for a file before clicking the upload button.";
exit();
} else if($fileSize > 5242880) { // if file size is larger than 5 Megabytes
echo "ERROR: Your file was larger than 5 Megabytes in size.";
unlink($fileTmpLoc); // Remove the uploaded file from the PHP temp folder
exit();
} else if (!preg_match("/.(gif|jpg|png)$/i", $fileName) ) {
// This condition is only if you wish to allow uploading of specific file types
echo "ERROR: Your image was not .gif, .jpg, or .png.";
unlink($fileTmpLoc); // Remove the uploaded file from the PHP temp folder
exit();
} else if ($fileErrorMsg == 1) { // if file upload error key is equal to 1
echo "ERROR: An error occured while processing the file. Try again.";
exit();
}
// END PHP Image Upload Error Handling ----------------------------------
// Place it into your "uploads" folder mow using the move_uploaded_file() function
$moveResult = move_uploaded_file($fileTmpLoc, "uploads/$fileName");
// Check to make sure the move result is true before continuing
if ($moveResult != true) {
echo "ERROR: File not uploaded. Try again.";
exit();
}
?>
Thank you, but I’m not looking to replace the script I have.
The uploader.php is only part of a much larger script.
Any help with what I’ve posted will be greatly appreciated.
You probably seriously want to consider replacing your script, it uses the mysql_* extension which was removed from version 7 of PHP. Also it’s considered bad practice to just supress errors, all errors that you surpress with the @ operator should be logged and handled
I’d expect that the “Choose File” button is just an <input type="file"> in the html, and the upload button simply the submit button with a different value. What are you trying to change in the way that the file is chosen?
You should be because it uses code that was flagged for removal from PHP back in 2012 and which was actually removed from PHP in 2015 - the next time your host upgrades PHP your script will fail.