SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2007
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Upload Form Not Recognizing File Field?!

    Im trying to get the script to validate the "trailer" field and see if the movie trailer uploaded is in the quicktime .mov format. If it isn't, i want $ok = "no" and $reply = $reply."<br> - Please make sure that your trailer is in the Quicktime .mov format.<br>";

    The script isnt working even when i upload a .mov file, it says that it isn't the right file format.

    I tried doing a test of
    PHP Code:
    echo $_FILES['trailer']['type']; 
    but it didnt do anything.

    Anyone help?



    PHP Code:
    <?
    include("header.php"); 
    $reply "Please fill out the form below to add a new movie to the site.<br>";

    if(isset(
    $_POST['submit'])){
        
    $pass $_POST['pass'];
        
    $access "123";
        
    $ok "yes";
        
        if(
    $pass != $access){
            
    $ok "no";
            
    $reply $reply."<br> - The password you entered is incorrect. Please enter the correct password to continue<br>";
        } else {
            
    $title $_POST['title'];
            
    $title_nospace str_replace(" ""_"$title);
            
    $year $_POST['year'];
            
    $syn $_POST['syn'];
            
    $poster $_FILES['poster']['name'];
            
    $trailer $_FILES['trailer']['name'];
            
    $screen1 $_FILES['screen1']['name'];
            
    $screen2 $_FILES['screen2']['name'];
            
    $screen3 $_FILES['screen3']['name'];
            
    $screen4 $_FILES['screen4']['name'];
            
    $quicktime "video/quicktime";
            
    $trailer_type $_FILES['trailer']['type'];
            
            if(empty(
    $title)){
                
    $ok "no";
                
    $reply $reply."<br> - Please enter the title of the movie.<br>";
            }
            if(empty(
    $year)){
                
    $ok "no";
                
    $reply $reply."<br> - Please enter the year the movie was released.<br>";
            }
            if(!(
    $trailer_type == $quicktime)){
                
    $ok "no";
                
    $reply $reply."<br> - Please make sure that your trailer is in the Quicktime .mov format.<br>";
            } else {
                
    $reply "Your trailer file format is correct!";
            }

        }
        
        if(
    $ok == "yes"){
            
    $reply "<b>Your movie information has been added successfully!</b>";
        }
    }
    ?>

  2. #2
    SitePoint Guru Ize's Avatar
    Join Date
    Nov 2005
    Location
    The Netherlands
    Posts
    809
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try print_r ($_FILES]; and see what it prints out.

  3. #3
    SitePoint Enthusiast
    Join Date
    Jun 2007
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it posted

    Array ( )




    i dont think that php file is turned on where it displays your errors? because everytime i leave out a ";" at the end of a line, the page just comes up blank. how do you turn that on? and what does the array above mean?

  4. #4
    SitePoint Evangelist
    Join Date
    Aug 2005
    Posts
    453
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you read the online documentation :
    http://us.php.net/features.file-upload

    It states : The mime type of the file, if the browser provided this information. An example would be "image/gif". This mime type is however not checked on the PHP side and therefore don't take its value for granted.

    As Ize suggested echo this value and see what value exist.
    Computers and Fire ...
    In the hands of the inexperienced or uneducated,
    the results can be disastrous.
    While the professional can tame, master even conquer.

  5. #5
    SitePoint Enthusiast
    Join Date
    Jun 2007
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i did, and it showed up

    Array ()

  6. #6
    SitePoint Evangelist
    Join Date
    Aug 2005
    Posts
    453
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    echo : $_FILES['trailer']['type']
    Computers and Fire ...
    In the hands of the inexperienced or uneducated,
    the results can be disastrous.
    While the professional can tame, master even conquer.

  7. #7
    SitePoint Evangelist
    Join Date
    Aug 2005
    Posts
    453
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i looked over your above post and read the documentation.
    Is your file_uploads set to "1" in your php.ini file?
    Is your upload_tmp_directory set to be writeable?
    Is your upload_max_filesize large enough for the file you are trying to upload?
    Is your post_max_filesize larger than your upload_max_filesize ?
    Is your max_input_time longer than the time it takes to upload the file ?
    Did you declare the form enctype="multipart/form-data" ?
    Do you have a hidden field max_input_size before the file input field ?

    If you answered no to any of these questions then your file will not upload and the $_FILES array will be empty....
    Computers and Fire ...
    In the hands of the inexperienced or uneducated,
    the results can be disastrous.
    While the professional can tame, master even conquer.

  8. #8
    SitePoint Enthusiast
    Join Date
    Jun 2007
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ah! thanks byron! yeah, i realized the file i was trying to get the info of is bigger than my max upload limit in my php.ini....

    Unfortunately, i don't have access to my php.ini file so i cant change that... or can i?

    is there any way to change that part of the php.ini file because the phpinfo(); says that my php.ini file is on C://WINDOWS/php.ini but i don't have access to that because i am a shared account on godaddy....


    any help?

  9. #9
    SitePoint Evangelist
    Join Date
    Aug 2005
    Posts
    453
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Put in a service request, most web hosting companies are willing to make ini changes for clients. Worst that can happen is godaddy denies your request.

    P.S. You might want to check max_execution_time in the ini file also, this determines how long a script is allowed to execute. Users with slower connections will exceed the default (60 seconds)....
    Computers and Fire ...
    In the hands of the inexperienced or uneducated,
    the results can be disastrous.
    While the professional can tame, master even conquer.


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
  •