Video Uploads
| From: | Jay Fitzgerald | Date: | Tue, 09 Nov 2004 17:10:53 +0000 |
| Subject: | Video Uploads | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-201628@lists.php.net to get a copy of this message | ||
I can upload just about everything with this script; but I don't understand why it says that the videos i try to upload are zero length.
------------------------------
THE FORM
------------------------------
<form method="post" name="info" enctype="multipart/form-data" id="x-form" action="add.php">
<input type="hidden" name="max_size" value="51200000">
<input type="file" name="form_data">
<input type="submit" name="submit" value="Add Video"></form>
------------------------------
THE SCRIPT
------------------------------
ini_set ('display_errors', '1');
ini_set ('error_reporting', E_ALL);
if (empty($_POST['submit']))
{
include ('addform.php');
}
else
{
$path = '/home/mydir/public_html/news/videos/'.$_FILES['form_data']['name'];
$url = 'http://www.mysite.com/news/videos/';
$_POST = array_merge($_POST, $_FILES);
if (!empty($_FILES['form_data']['name']))
{
if ($_FILES['form_data']['size'] == 0)
{
echo 'Problem: '.$_FILES['form_data']['name'].' is zero length';
}
if ($_FILES['form_data']['size'] > $_POST['max_size'])
{
echo 'Problem: '.$_FILES['form_data']['name'].' is over '.$_POST['max_size'].' bytes.';
}
if (!is_uploaded_file($_FILES['form_data']['tmp_name']))
{
echo $_FILES['form_data']['name'].' is not uploaded.';
}
move_uploaded_file($_FILES['form_data']['tmp_name'], $path);} }