Jump to content

PHP and big files


LLeoun

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.