Jump to content


Video Uploading script

  • Please log in to reply
1 reply to this topic

#1 joecooper

  • Members
  • PipPipPip
  • Advanced Member
  • 358 posts

Posted 18 April 2006 - 08:18 PM

this is the main file upload.php

<p><font face="Verdana" color="#00000" size="+1"><u><b>Essexracers.com Video 
<font face="Verdana">Click on 'Browse...' to select the file you wish to upload 
then click on 'Upload'<br><font size="2">Note: The file upload process may take 
up to 10 minutes to upload with higher file sizes, <u><b>Maximum 12 megs.</b></u></font></font><font face="Verdana" color="#00000" size="0"><br>
<font size="2">No uploading copyrighted / illegal material. Not for outside 
EssexRacers.com use.<br>
By uploading your own video's, we have the right to use them / delete them 
without notice.</font></font></p>
<p><font face="Verdana" size="2">Accepted formats: .wmv | .mpg | .mpeg | .avi | 
.mov | .rm | .mp4 | .asf<br>Contact <a href="mailto:joe@joeyjoe.co.uk">joe@joeyjoe.co.uk</a>
if you need a different file format uploaded!</font></p>
<form enctype="multipart/form-data" action="videoupload.php" method="POST">
    <!-- MAX_FILE_SIZE must precede the file input field -->
    <input type="hidden" name="MAX_FILE_SIZE" value="30000" />
    <!-- Name of input element determines name in $_FILES array -->
    <p align="center">
    <font size="2" face="Verdana" color="#00000">Video to upload:</font> 
    <input name="userfile" type="file" size="18" />
    <input type="submit" value="Upload" /> </p>
<p align="center">&nbsp;</p>

and heres the processing file

$uploaddir = '/home/essexrac/public_html/videoupload/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
$vidfilename = basename($_FILES['userfile']['name']);

$goodType = array ('video/x-ms-wmv ','video/mpeg','video/x-msvideo');

if (in_array($_FILES['userfile']['type'], $goodType)) {
echo '<pre>';
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
   echo "Video uploaded to: http://www.essexraces.com/videoupload/$vidfilename\n";
} else {
   echo "There was an error uploading the video!\n";

echo 'Here is some more debugging info:';

print "</pre>";
echo "File isnt within the allowed formats!<br>";
echo "Accepted formats: .wmv | .mpg | .mpeg | .avi | .mov | .rm | .mp4 | .asf";

The file size limiter doesnt work, and also, it uploads the file taking ages before it tells u that the filesize is wrong. how can i make it do it straigt away? what do i change to make the file size limit 12 megs?
[a href="http://www.planet-so...=1999&lngWId=8" target="_blank"]EzLogin 1.0[/a]
[a href="http://www.essexracers.com" target="_blank"]Essexracers.com[/a]
Msn Messenger: joe@joeyjoe.co.uk

#2 poirot

  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 19 April 2006 - 04:25 AM

Well, you can't know the filesize before the user actually sends it; unless you use some client-sided applet to verify it before sending.

About the file size, you must change the "upload_max_filesize" setting, which is usually 2MB
Note that this option can be set in php.ini or httpd.conf only.
~ D Kuang

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users