SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: Uploading Help

  1. #1
    SitePoint Enthusiast baddot's Avatar
    Join Date
    Nov 2006
    Posts
    73
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Uploading Help

    can anyone tell me how do i code a upload script for video like wmv rmvb flv avi mpeg ?
    Make Friends And Earn Money @ Zonity.com
    Make Money at BadDot.com

  2. #2
    SitePoint Zealot chrisdpucci's Avatar
    Join Date
    Dec 2006
    Location
    On the internets
    Posts
    191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You would write it the exact same way you do any upload script.

    http://www.google.com/search?hl=en&q...e+Search&meta=

    The only difference would be if you want to limit it to only video file types then you would need to put in a file type checking routine to validate the file. There are two ways to do that, either using the file's extension or MIME type. Both have their ups and downs but I prefer MIME type validation.

  3. #3
    SitePoint Enthusiast
    Join Date
    Apr 2006
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello,
    This may run for you.
    As you can see add the extension in line 2

    if ($upload="upload"&&$superdat_name){
    if (!eregi("\.(avi|flv|etc)$",$superdat_name)){
    print "<b>unsuported file</b>";
    }else{
    $superdat_name = preg_replace(
    '/[^a-zA-Z0-9\.\$\&#37;\'\`\-\@\{\}\~\!\#\(\)\&\_\^]/'
    ,'',str_replace(array(' ','%20'),array('_','_'),$superdat_name));
    if(strlen($superdat_name)>53){ print "<b>file name to long</b>";
    }else{
    if (empty($superdat)) {
    print "<b>no input file specified</b>";
    }else{
    copy("$superdat", "upload_directory/$superdat_name") or
    die("couldn't copy file.");

    $date=(date("D, j F Y"));

    $fsize=round($superdat_size/1024,1);

    $text = "&&$superdat_name&&$fsize KB&&$date&&$REMOTE_ADDR&&";
    $text=strip_tags($text);
    $text = ereg_replace("\n", " ", $text);
    $text = ereg_replace("\r", "", $text);
    $text = ereg_replace("~", "-", $text);
    $text = str_replace('$', '$$', $text);
    $xfile = @file("upload_directory");
    $xfile = array_reverse($xfile);
    $check = explode("&&",$xfile[0]);
    if("$text"!="$check[1]"){

    $fp=@fopen("upload_directory","a");
    @fputs($fp,"$text \r\n");
    @fclose($fp);

    }
    echo "<b>$superdat_name</b> has been successfully uploaded";
    }
    }
    }
    }
    ?>
    <FORM ACTION="THIS PAGE" METHOD="POST" ENCTYPE="multipart/form-data">
    <input type="file" name="superdat">
    <input type="hidden" name="upload" value="upload"/><br/>
    <INPUT TYPE=SUBMIT NAME="submit" VALUE="upload file"><br/>

  4. #4
    SitePoint Enthusiast baddot's Avatar
    Join Date
    Nov 2006
    Posts
    73
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question

    Quote Originally Posted by blackhowk View Post
    Hello,
    This may run for you.
    As you can see add the extension in line 2

    if ($upload="upload"&&$superdat_name){
    if (!eregi("\.(avi|flv|etc)$",$superdat_name)){
    print "<b>unsuported file</b>";
    }else{
    $superdat_name = preg_replace(
    '/[^a-zA-Z0-9\.\$\%\'\`\-\@\{\}\~\!\#\(\)\&\_\^]/'
    ,'',str_replace(array(' ','%20'),array('_','_'),$superdat_name));
    if(strlen($superdat_name)>53){ print "<b>file name to long</b>";
    }else{
    if (empty($superdat)) {
    print "<b>no input file specified</b>";
    }else{
    copy("$superdat", "upload_directory/$superdat_name") or
    die("couldn't copy file.");

    $date=(date("D, j F Y"));

    $fsize=round($superdat_size/1024,1);

    $text = "&&$superdat_name&&$fsize KB&&$date&&$REMOTE_ADDR&&";
    $text=strip_tags($text);
    $text = ereg_replace("\n", " ", $text);
    $text = ereg_replace("\r", "", $text);
    $text = ereg_replace("~", "-", $text);
    $text = str_replace('$', '$$', $text);
    $xfile = @file("upload_directory");
    $xfile = array_reverse($xfile);
    $check = explode("&&",$xfile[0]);
    if("$text"!="$check[1]"){

    $fp=@fopen("upload_directory","a");
    @fputs($fp,"$text \r\n");
    @fclose($fp);

    }
    echo "<b>$superdat_name</b> has been successfully uploaded";
    }
    }
    }
    }
    ?>
    <FORM ACTION="THIS PAGE" METHOD="POST" ENCTYPE="multipart/form-data">
    <input type="file" name="superdat">
    <input type="hidden" name="upload" value="upload"/><br/>
    <INPUT TYPE=SUBMIT NAME="submit" VALUE="upload file"><br/>
    hi thanks all but i tired but it cant support more than 30 megs
    Make Friends And Earn Money @ Zonity.com
    Make Money at BadDot.com

  5. #5
    SitePoint Zealot chrisdpucci's Avatar
    Join Date
    Dec 2006
    Location
    On the internets
    Posts
    191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by baddot View Post
    hi thanks all but i tired but it cant support more than 30 megs
    That could be an issue with your web server's configuration. On your php info page, what settings do "post_max_size" and "upload_max_filesize" have?

    If you have access to your php.ini you can change those settings yourself, otherwise you'll have to override them in the script itself.

  6. #6
    SitePoint Enthusiast baddot's Avatar
    Join Date
    Nov 2006
    Posts
    73
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    tried it cant work too
    Make Friends And Earn Money @ Zonity.com
    Make Money at BadDot.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
  •