Jump to content

How to upload Video File using PHP?


sridaran

Recommended Posts

Hi Can any one tell me how to upload video files using PHP Script? Here is my PHP Code for image file uploading:<?phpif(isset($_POST['Submit'])){$current_image=$_FILES['image']['name'];$extension = substr(strrchr($current_image, '.'), 1);if (($extension!= "jpg") && ($extension != "jpeg")) {die('Unknown extension');}$new_image = $time . "." . $extension;$destination="uploads/".$new_image;$action = copy($_FILES['image']['tmp_name'], $destination);if (!$action) {die('File copy failed');}else{echo "File uploaded successfully";}}else{?><form method="post" enctype="multipart/form-data" action="fileupload.php"><input type="file" name="image" ><br><input type="submit" name="Submit" value="submit"></form><?php}?>R.Sridaran

Link to comment
Share on other sites

The process is exactly the same for any type of file - just change the extension-checking part of the code. Also, PHP has a size limit for uploads, which video files are more likely to exceed. That can be changed in php.ini.

Link to comment
Share on other sites

Thanks to sridaran and Synook. I'm going to need to write a files upload load script and this thread led me to http://www.w3schools.com/PHP/php_file_upload.asp. I might have found the tut anyway, but now its top of the mind. Thanks again for giving me a boost.Niche

Link to comment
Share on other sites

Thank you very much. Now I edited the correct php.ini file by checking the file path and uploaded the video files. Can you please tell me tha MIME type for video files(like image/jpeg, image/png...etc). I need to set conditions to allow upload for certain video files only.R.Sridaran

Link to comment
Share on other sites

http://www.w3schools.com/media/media_mimeref.asp. Note that the script as posted originally checks the extension, not the Internet media type (which is not, technically, an intrinsic property of a file unless it is being sent over certain network protocols such as HTTP or SMTP).
Link to comment
Share on other sites

  • 2 weeks later...

Archived

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

×
×
  • Create New...