Jump to content

Image upload script into a Video Upload script ...


techiefreak05

Recommended Posts

I have the following script that works very well for images. and im looking to start a video upload feature, how would i change the following script to a video upload script? I heard that i could just change my script to let videos and it should work.

 

<?php
//print_r($_POST);

if($_POST["action"] == "-Upload-")
{
unset($imagename);

if(!isset($_FILES) && isset($HTTP_POST_FILES))
$_FILES = $HTTP_POST_FILES;

if(!isset($_FILES['image_file']))
$error["image_file"] = "An image was not found.";


$imagename = basename($_FILES['image_file']['name']);
//echo $imagename;

  //$max_space = 524288;
  $files = array("image/gif", // Gif
        "image/jpeg", // jpe jpeg jpg
        "png", // PNG
         "image/JPEG",
        );
  $picfile_size = $_FILES['image_file']['size'];
  $picfile_type = $_FILES['image_file']['type'];
  
  if(! in_array($picfile_type, $files)) {
   $error = "<b>File was not allowed! Only gif,png,jpg,jpeg</b>";
  }

if(empty($imagename))
$error["imagename"] = "The name of the image was not found.";

if(empty($error)){
$newimage = "files/uploads/" . $_SESSION[username] . "/" . $imagename;

mysql_query("INSERT INTO `images` ( `imgPath` , `headline` , `id` , `userid`, `aID`)
VALUES ('http://s191754240.onlinehome.us/$newimage', '', '', '$_SESSION[id]', '$_POST[album_select]');") or die(mysql_error());
echo "<meta http-equiv=\"refresh\" content=\"0;url=managePhotos.php\">";
?>

<font color="red"><b>Image Upload Successful!</b></font>
<?php
$result = @move_uploaded_file($_FILES['image_file']['tmp_name'], $newimage);
if(empty($result))
$error["result"] = "There was an error moving the uploaded file.";
}
}
echo $error.$error["image_file"] 
?>

change

  $files = array("image/gif", // Gif
        "image/jpeg", // jpe jpeg jpg
        "png", // PNG
         "image/JPEG",
        );

 

to include the video types you wish to upload

 

ie

  $files = array("image/gif", // Gif
        "image/jpeg", // jpe jpeg jpg
        "png", // PNG
         "image/JPEG",
"video/x-msvideo",
"video/quicktime",
"video/mpeg",
        );

 

here a nice referance

http://www.w3schools.com/media/media_mimeref.asp

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.