I have an upload form that works well for small files but when I try to upload video files of a large size it times out. How can I edit this so that I can upload say 100-150MB video files no problem.
PHP Code:
<?php
$upload_dir = "uploads/";
$num_files = 5;
//the file size in bytes.
$size_bytes =104857600; //51200 bytes = 50KB.
//Extensions you want files uploaded limited to.
$limitedext = array(".gif",".jpg",".jpeg",".mpeg",".wav",".avi",".zip",".exe");
//check if the directory exists or not.
if (!is_dir("$upload_dir")) {
die ("Error: The directory <b>($upload_dir)</b> doesn't exist. Please see a Teamwork Administrator for assistance.");
}
//check if the directory is writable.
if (!is_writeable("$upload_dir")){
die ("Error: The directory <b>($upload_dir)</b> is NOT writable, Please CHMOD (777). Please see a Teamwork Administrator for assistance.");
}
//if the form has been submitted, then do the upload process
//infact, if you clicked on (Upload Now!) button.
if (isset($_POST['upload_form'])){
echo "<h3>Upload results:</h3><br>";
//do a loop for uploading files based on ($num_files) number of files.
for ($i = 1; $i <= $num_files; $i++) {
//define variables to hold the values.
$new_file = $_FILES['file'.$i];
$file_name = $new_file['name'];
//to remove spaces from file name we have to replace it with "_".
$file_name = str_replace(' ', '_', $file_name);
$file_tmp = $new_file['tmp_name'];
$file_size = $new_file['size'];
#-----------------------------------------------------------#
# this code will check if the files was selected or not. #
#-----------------------------------------------------------#
if (!is_uploaded_file($file_tmp)) {
//print error message and file number.
echo "File $i: Not selected.<br><br>";
}else{
#-----------------------------------------------------------#
# this code will check file extension #
#-----------------------------------------------------------#
$ext = strrchr($file_name,'.');
if (!in_array(strtolower($ext),$limitedext)) {
echo "File $i: ($file_name) Wrong file extension. Please see a Teamwork Administrator for assistance.<br><br>";
}else{
#-----------------------------------------------------------#
# this code will check file size is correct #
#-----------------------------------------------------------#
if ($file_size > $size_bytes){
echo "File $i: ($file_name) Faild to upload. File must be no larger than <b>100 MB</b> in size. Please see a Teamwork Administrator for assistance.<br><br>";
}else{
#-----------------------------------------------------------#
# this code check if file is Already EXISTS. #
#-----------------------------------------------------------#
if(file_exists($upload_dir.$file_name)){
echo "File $i: ($file_name) already exists. Please see a Teamwork Administrator for assistance.<br><br>";
}else{
#-----------------------------------------------------------#
# this function will upload the files. :) ;) cool #
#-----------------------------------------------------------#
if (move_uploaded_file($file_tmp,$upload_dir.$file_name)) {
echo "File $i: ($file_name) has been uploaded successfully. A Teamwork Administrator has been notified of the upload, Thank You!<br><br>";
}else{
echo "File $i: Faild to upload. Please see a Teamwork Administrator for assistance.<br><br>";
}#end of (move_uploaded_file).
}#end of (file_exists).
}#end of (file_size).
}#end of (limitedext).
}#end of (!is_uploaded_file).
}#end of (for loop).
# print back button.
echo " <br><a href=upload.php><input type=\"button\" name=\"back\" value=\"Back\"></a> <a href=media.html><input type=\"button\" name=\"redirect\" value=\"Finish\"></a> ";
////////////////////////////////////////////////////////////////////////////////
//else if the form didn't submitted then show it.
}else{
echo " <h3>Select files to upload!</h3>
Max File Size = 100 MB<br>
Allowed File Types = gif, jpg, jpeg, mov, wav, avi, zip";
echo " <br><br><br><br> <form method=\"post\" action=\"$_SERVER[PHP_SELF]\" enctype=\"multipart/form-data\">";
// show the file input field based on($num_files).
for ($i = 1; $i <= $num_files; $i++) {
echo "File $i: <input type=\"file\" size=\"70\" name=\"file". $i ."\"><br><br>";
}
echo " <input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"$size_bytes\">
<blockquote>
<br><br>
<input type=\"submit\" name=\"upload_form\" value=\"Upload\"> <input type=\"reset\" name=\"reset\" value=\"Reset\"> <a href=media.html><input type=\"button\" name=\"redirect\" value=\"Cancel\"></a>
<br><br>PLEASE ONLY PRESS UPLOAD ONCE!<br>The upload may take time to complete.
</blockquote>
</form>";
}
?>
Either a solution to edit this to work with such large files or another way to upload these large video files to an ftp server in the same way that this form is created. I want to be able to do this within an html web page or a php web page.Is this possible? I know very little about this and would like any help possible. Thanks.
Bookmarks