SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Addict madproject.com's Avatar
    Join Date
    Jan 2003
    Location
    Ottawa, Canada
    Posts
    268
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Uploading Files Issue

    People can upload videos up to 5mbs to my server, however the problem I've encountered is that any file over about 1.3mbs I get an error where it says that:
    Code:
     The following errors were encountered: 
    • Invalid or missing entry: Video
    I guess all you can do now is hit back and try again
    I coded the above error handling in the case that somebody didn't select any video to upload, but it seems like after a certain amount of time(while the file is uploading), the variable containing the file info gets lost and I get this error. I'm not sure.. Please help. Smaller files cause no problem though.
    PHP Code:
     <?
    include("lvl0security.php" );
    if (!
    $submit) { 
    ?>
    <link rel="stylesheet" type="text/css" href="addevent.css" />

    <center>
    <div style="border: 1px black solid; width: 50%; margin:5px; background-color: #d7d7d7;">
    <div style="border-top:1px #ffffff solid; border-left:1px #ffffff solid;">
    <font size="3"><b>Add Video</b></font>
    </div>
    </div>
    <form method="post" action="<?php PHP_SELF ?>" ENCTYPE="multipart/form-data">
    <table width="80%" border="0" cellpadding="5">
    <tr>
    <td width="50%" align="right">
    Title:
    </td>
    <td width="50%" align="left">
    <input class="fix" type="Text" name="videotitle" size="20" />
    </td>
    </tr>
    <tr>
    <td width="50%" align="right">
    Video Description:
    </td>
    <td width="50%" align="left">
    <textarea class="fix" name="videodesc" rows="10" cols="40" wrap="physical" onKeyDown="textCounter(this.form.videodesc,this.form.remLen,200);" onKeyUp="textCounter(this.form.videodesc,this.form.remLen,200);"></textarea><br />
    <input readonly type="text" name="remLen" size=3 maxlength=3 value="200" /> characters left
    </td>
    </tr>
    <tr>
    <td width="50%" align="right">
    <font color="#FF0000">*</font>Video<font size="-2">(5Mb max)</font>:
    </td>
    <td width="50%" align="left">
    <input type="file" name="file" size="30">
    </td>
    </tr>
    </table>
    <input type="hidden" name="videouser" size="20" value="<? echo $username?>" />
    <input class="sub" type="Submit" name="submit" value="Add Event" />
    </form>
    </center>

    <? } else {
    // set up error list array
    $errorList = array();
    $count 0;

    // validate text input fields
    if (!$videotitle) { $errorList[$count] = "Invalid or missing entry: Title"$count++; }

    if (!
    $videodesc) { $errorList[$count] = "Invalid or missing entry: Video Description"$count++; }

    if (!
    $file) { $errorList[$count] = "Invalid or missing entry: Video"$count++; }

    // check for errors
    // if none found...
    if (sizeof($errorList) == 0) {
    //Upload picture
    $extlimit "yes"//Do you want to limit the extensions of files uploaded
    $limitedext = array(".mov",".mpeg",".mpg",".avi",".wmv" ); //Extensions you want files uploaded limited to.
    $sizelimit "yes"//Do you want a size limit, yes or no?
    $sizebytes "5242880"//size limit in bytes
    $dl "[url=http://www.madproject.com/upload][color=#0000ff]http://www.madproject.com/upload[/color][/url]"//url where files are uploaded
    $absolute_path "/someplace/html/upload"//Absolute path to where files are uploaded
    $websiteurl "[url=http://www.madproject.com/][color=#800080]http://www.madproject.com[/color][/url]"//Url to you website
    $websitename "MadProject / Audible - 07 Productions"
    if (
    $file != "" ) {
    if (
    file_exists("$absolute_path/$file_name)) { ?>
    <div style="padding: 10px;">Status: <b>Failed, a file with the same name already exists</b></div>
    <? }

    if ((
    $sizelimit == "yes" ) && ($file_size $sizebytes)) { ?>
    <div style="padding: 10px;">Status: <b>Failed, file is too big.</b></div>
    <? }

    $ext strrchr($file_name,'.'); 
    if ((
    $extlimit == "yes" ) && (!in_array($ext,$limitedext))) { ?>
    <div style="padding: 10px;">Status: <b>Failed, wrong file extension</b></div>
    <? }

    @
    copy($file"$absolute_path/$file_name) or die("The file you are trying to upload couldn't be copied to the server" );
    }
    //Done upload picture

    $videourl "[url=http://www.madproject.com/upload/$file_name][color=#0000ff]http://www.madproject.com/upload/$file_name[/color][/url]"

    $videodesc strip_tags($videodesc'<a><b><i><u><ul><li>');

    include(
    "common.php" ); //Connect to Database
    $query "INSERT INTO madvideos (videotitle,videouser,videodate,videodesc,videourl) VALUES ('$videotitle','$videouser',NOW(),'$videodesc','$videourl')";
    $result mysql_query($query) or die ("Error in query: $query." mysql_error());
    ?> <div style="padding: 10px;">Status: <b>Video successfuly added</b></div> <?

    // close database connection
    mysql_close($db);
    } else {
    // errors found
    // print as list
    ?><div style="padding: 10px;"><?
    echo "<font size=-1><b>The following errors were encountered:</b> <br>";
    echo 
    "<ul>";
    for (
    $x=0$x<sizeof($errorList); $x++)
    {
    echo 
    "<li>$errorList[$x]";
    }
    echo 
    "</ul><b>I guess all you can do now is hit back and try again.</b></font>";
    ?></div><?
    }
    }
    Free Picture and Video Hosting
    [http://photocabin.com][http://madproject.com]

  2. #2
    SitePoint Evangelist
    Join Date
    Nov 2001
    Location
    UK
    Posts
    466
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    check your phpinfo() for the upload resrtictions

    file_uploads On On
    max_execution_time 30 30
    upload_max_filesize 2M 2M

    those are roughly default settings - you would want max_exec of a fair few minutes - say 360 and upload_max set above the highest filesize

    some hosts allow tinkering with the php.ini through
    ini_set('upload_max_filesize','6M');
    most don't though.
    teckis - that's news to me.

  3. #3
    SitePoint Zealot codezilla's Avatar
    Join Date
    Nov 2002
    Location
    upstairs
    Posts
    110
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Check out post_max_size too. upload_max_filesize could be 10GB but if post_max_size is only 8MB, then uploads will be limited to 8MB.

  4. #4
    SitePoint Addict madproject.com's Avatar
    Join Date
    Jan 2003
    Location
    Ottawa, Canada
    Posts
    268
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you so much, nobody was able to answer my question and I knew my code wasn't bad. Thanks again and again!
    Free Picture and Video Hosting
    [http://photocabin.com][http://madproject.com]

  5. #5
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Happy people are riding something


    Usually the wife...

  6. #6
    SitePoint Addict madproject.com's Avatar
    Join Date
    Jan 2003
    Location
    Ottawa, Canada
    Posts
    268
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You should see the my company stickers that goes with the quote
    Free Picture and Video Hosting
    [http://photocabin.com][http://madproject.com]


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
  •