sridaran Posted September 3, 2010 Share Posted September 3, 2010 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 More sharing options...
Synook Posted September 3, 2010 Share Posted September 3, 2010 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 More sharing options...
niche Posted September 3, 2010 Share Posted September 3, 2010 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 More sharing options...
sridaran Posted September 6, 2010 Author Share Posted September 6, 2010 Hi I changed the upload file size as upload_max_filesize = 10M in php.ini file. But it is showing filesize as 2M while running phpinfo(). Now I am unable to upload files more than 2MB size. Any other solution is there?R.Sridaran Link to comment Share on other sites More sharing options...
justsomeguy Posted September 6, 2010 Share Posted September 6, 2010 Make sure you're editing the correct php.ini, the phpinfo page will list which file it uses. Link to comment Share on other sites More sharing options...
sridaran Posted September 7, 2010 Author Share Posted September 7, 2010 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 More sharing options...
Synook Posted September 7, 2010 Share Posted September 7, 2010 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 More sharing options...
Sami Posted September 16, 2010 Share Posted September 16, 2010 If you're using a unix server, you'll need to restart the web server software before the changes will work.(sudo /etc/init.d/apache2 restart) Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.