LLeoun Posted February 25, 2008 Share Posted February 25, 2008 Dear people, I'm trying upload videos using an html form and a PHP script. First I uploaded them into a Mysql database table, breaking them into smaller chunks. Whenever I try to put them together and download the video, the result was a video player error message saying it was corrupted. Then I uploaded the videos into a web folder and I stored the path into a MySql table so I can query as I want in order to show them. Again, the videos were corrupted when downloading them. I tried to upload anything that was not a video.. and a full of data text file when downloaded was empty. Last, I tried to ftp the videos using php's ftp function. The videos are uploaded into my web folder with ridiculous sizes, obviously they are corrupted. I won't give up, but I need your help .. what am I doing wrong? How does PHP behave with big files as videos? :-\ Thanks a lot in advance! Link to comment https://forums.phpfreaks.com/topic/92915-php-and-big-files/ Share on other sites More sharing options...
darkfreaks Posted February 25, 2008 Share Posted February 25, 2008 you should use the $_FILE function in PHP for videos and pictur ;Des Link to comment https://forums.phpfreaks.com/topic/92915-php-and-big-files/#findComment-475980 Share on other sites More sharing options...
LLeoun Posted February 25, 2008 Author Share Posted February 25, 2008 Thanks for answering darkfreaks. I'm already using $_FILE .. Link to comment https://forums.phpfreaks.com/topic/92915-php-and-big-files/#findComment-475992 Share on other sites More sharing options...
Orio Posted February 25, 2008 Share Posted February 25, 2008 Can you show us some code? Orio. Link to comment https://forums.phpfreaks.com/topic/92915-php-and-big-files/#findComment-475994 Share on other sites More sharing options...
darkfreaks Posted February 25, 2008 Share Posted February 25, 2008 post your code so i can better help Link to comment https://forums.phpfreaks.com/topic/92915-php-and-big-files/#findComment-475997 Share on other sites More sharing options...
LLeoun Posted February 25, 2008 Author Share Posted February 25, 2008 Yeah, sorry guys, here it goes: This is the code for uploading the path into a Mysql table and the videos into a web folder. Seems to be working correctly. The size field stored in the database shows the correct size of the videos: <?php $name = $_FILES['uploaded']['name']; $tmp_name = $_FILES['uploaded']['tmp_name']; $target = "upload/"; $target = $target . basename( $_FILES['uploaded']['name']) ; $filePath = $target . $name; $ok=1; if ($uploaded_size > 35000000) { echo "The video file is too big.<br>"; $ok=0; } if ($uploaded_type =="mov/wmv") { echo "This is not a valid video format<br>"; $ok=0; } if ($ok==0) { Echo "Sorry, the video was not uploaded"; } else { if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { $uploaded_size = $_FILES['uploaded']['size']; $uploaded_type = $_FILES['uploaded']['type']; include ("connection.php"); include ("library/config.php"); include ("library/opendb.php"); if(!get_magic_quotes_gpc()) { $fileName = addslashes($name); $filePath = addslashes($filePath); } $query = "INSERT INTO upload2 (name, size, type, path ) ". "VALUES ('$fileName', '$uploaded_size', '$uploaded_type', '$filePath')"; mysql_query($query) or die('Error, query failed : ' . mysql_error()); echo "The video file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded "; } else { echo "Sorry, there was a problem uploading the video."; } } ?> Link to comment https://forums.phpfreaks.com/topic/92915-php-and-big-files/#findComment-476030 Share on other sites More sharing options...
LLeoun Posted February 25, 2008 Author Share Posted February 25, 2008 And this is the download code Link to comment https://forums.phpfreaks.com/topic/92915-php-and-big-files/#findComment-476032 Share on other sites More sharing options...
darkfreaks Posted February 25, 2008 Share Posted February 25, 2008 <?php if ($uploaded_type =="mov"||$uploaded_type=="wmv") { exit ("This is not a valid video format<br>"); $ok=0; }?> see if changing that helps Link to comment https://forums.phpfreaks.com/topic/92915-php-and-big-files/#findComment-476033 Share on other sites More sharing options...
Orio Posted February 25, 2008 Share Posted February 25, 2008 Your uploading seems fine... I once had a funny problem- I had a system quite similar to yours... But in the downloading page, I also included the footer and so the files that were downloaded were "corrupted" (they had the footer data attached to them). Are you using force downloading to the files? Try downloading a file that you upload using this script via ftp and check it. If the file is still "corrupted" then we'll have a deeper look into the upload script (that seems fine in a first glance). But if it's not corrupted, it's the download script. If you are using a php file to download the files, it would be good if you show it too- the full code. Orio. Link to comment https://forums.phpfreaks.com/topic/92915-php-and-big-files/#findComment-476036 Share on other sites More sharing options...
LLeoun Posted February 25, 2008 Author Share Posted February 25, 2008 darkfreaks, sorry it didn't work And Orio, yes, when the files go to my web folder they are already corrupted .. I guess there's a problem then with the upload code. Anyway I'm trying to post the download code, but this page is kicking me.. Link to comment https://forums.phpfreaks.com/topic/92915-php-and-big-files/#findComment-476046 Share on other sites More sharing options...
Orio Posted February 25, 2008 Share Posted February 25, 2008 Beats me. Uploading seems ok, except the $filePath variable that holds a bit too much, but that can't cause the corruptions. Orio. Link to comment https://forums.phpfreaks.com/topic/92915-php-and-big-files/#findComment-476050 Share on other sites More sharing options...
LLeoun Posted February 25, 2008 Author Share Posted February 25, 2008 The download code: http://www.negopolis.tv/opinion/download.txt Link to comment https://forums.phpfreaks.com/topic/92915-php-and-big-files/#findComment-476052 Share on other sites More sharing options...
LLeoun Posted February 25, 2008 Author Share Posted February 25, 2008 Orio, I'm testing it locally using Apache .. can cause that the problem? Link to comment https://forums.phpfreaks.com/topic/92915-php-and-big-files/#findComment-476055 Share on other sites More sharing options...
LLeoun Posted February 25, 2008 Author Share Posted February 25, 2008 Now, I'm uploading all sorts of files and when going to my upload folder and opening them some files are showing an access denied error .. it doesn't make sense I'm testing locally :-\ Link to comment https://forums.phpfreaks.com/topic/92915-php-and-big-files/#findComment-476070 Share on other sites More sharing options...
Orio Posted February 25, 2008 Share Posted February 25, 2008 Try uploading a txt file, that holds a certain data. Then "upload" it and check what data now it holds (just drop the type check of course). Orio. Link to comment https://forums.phpfreaks.com/topic/92915-php-and-big-files/#findComment-476076 Share on other sites More sharing options...
darkfreaks Posted February 25, 2008 Share Posted February 25, 2008 <?php echo"<a href=donwload.php?id=$id>$name</a>";?> Link to comment https://forums.phpfreaks.com/topic/92915-php-and-big-files/#findComment-476078 Share on other sites More sharing options...
darkfreaks Posted February 25, 2008 Share Posted February 25, 2008 <?php if ($uploaded_type !="avi/mpg/mpeg") { echo "this is not a valid file";}?> Link to comment https://forums.phpfreaks.com/topic/92915-php-and-big-files/#findComment-476135 Share on other sites More sharing options...
darkfreaks Posted February 25, 2008 Share Posted February 25, 2008 also might wanna try limiting size to 100 megs Link to comment https://forums.phpfreaks.com/topic/92915-php-and-big-files/#findComment-476155 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.