Page 1 of 3 123 LastLast
Results 1 to 10 of 22

Thread: Video Upload Form

  1. #1
    Join Date
    Oct 2007
    Posts
    52
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Video Upload Form

    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.

  2. #2
    Join Date
    Oct 2007
    Posts
    52
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Anyone know how to change this upload script so that I can upload large video files to an ftp server but keep it in the same format as what is there if possible?

  3. #3
    Join Date
    Oct 2005
    Posts
    255
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    you have to do it thru ftp

    look here
    http://www.dynamicdrive.com/forums/s...ad.php?t=25477
    Hey new design new look, goto xudas for personal webdsign help.. (:

  4. #4
    Join Date
    Oct 2007
    Posts
    52
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Yeah, I have been looking at that thread for some time, but don't know how to incorporate it into my own. Or know the approach of using it with the current file upload script above. Any suggestions?

  5. #5
    Join Date
    Oct 2005
    Posts
    255
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    uhm well make a ftp account add in the details.. and, the only thing is i dont know how to post the urll etc...

    just play around with it and see what you get...
    Hey new design new look, goto xudas for personal webdsign help.. (:

  6. #6
    Join Date
    Oct 2007
    Posts
    52
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I don't know jack about php and coding such as this. I am a noob, got an steps or maybe a place for me to start.

  7. #7
    Join Date
    Oct 2005
    Posts
    255
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    well take the code(the updated version) put it into a file
    called- upload.php

    then insert your information for the ftp, if you made an account..
    then goto yourdomain.com/upload.php

    then try uploading something and then tell me if you see the file that you uploaded on your server..., if you get an error let me know and i will help you..
    Hey new design new look, goto xudas for personal webdsign help.. (:

  8. #8
    Join Date
    Oct 2007
    Posts
    52
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Sure, I will give it a try when I can. I am not at a computer that I can do code a the moment. Also the code in the post above, is that the "updated version" you are talking about? If it is, it doesn't look complete. If you want me to put FTP information into my code in the first post, I don't know how or know what to put, sorry. Or do I insert that code in the other forum thread into mine somewhere?

    I am sorry, I don't mean to be so stupid at this.

  9. #9
    Join Date
    Oct 2005
    Posts
    255
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    I cant seem to get it working either ill ask jas.. to give me source and see..
    Hey new design new look, goto xudas for personal webdsign help.. (:

  10. #10
    Join Date
    Oct 2007
    Posts
    52
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by insanemonkey View Post
    I cant seem to get it working either ill ask jas.. to give me source and see..
    Thanks for the help, and hope to hear from you when I can.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •