Jump to content

m4v mp4 ogv and web files will not upload


teknospr

Recommended Posts

Good day:

 

I have a simple uploader form to upload video files. FLV and mpg files will upload without problems. But mp4, m4v, ogg and webm files will not upload. I get this error:

 

Warning: copy() [function.copy]: Unable to access in /mounted-storage/home7/sub007/sc30390-PTUD/**********.com/admin123/insertvideo.php on line 32

Error Video not loaded.

 

I have read about adding the files in config/mimes.php but I do not see that folder or files in my hosting service (which is servage).

 

Any help will be appreciated.

 

 

Thanks.

Link to comment
Share on other sites

Just a simple upload form. This is the code that does the actual upload:

 

<html>
<body bgcolor="#FFFFFF">

<?php

$mydate = isset($_REQUEST["date5"]) ? $_REQUEST["date5"] : "";


// Your file name you are uploading
$file_name = $HTTP_POST_FILES['video']['name'];
$file_type = $HTTP_POST_FILES['video']['type'];




// random 4 digit to add to our file name
// some people use date and time in stead of random digit
$random_digit=rand(0000,9999);

//combine random digit to you file name to create new file name
//use dot (.) to combile these two variables

$new_file_name=$random_digit.$file_name;

//set where you want to store files

$path= "../videos/".$new_file_name;
if($ufile !=none)
{
if(copy($HTTP_POST_FILES['video']['tmp_name'], $path))
{
echo "Video agregado <BR/>";

//$new_file_name = new file name
//$HTTP_POST_FILES['ufile']['size'] = file size
//$HTTP_POST_FILES['ufile']['type'] = type of file
echo "File Name :".$new_file_name."<BR/>";
echo "File Size :".$HTTP_POST_FILES['video']['size']."<BR/>";
echo "File Type :".$HTTP_POST_FILES['video']['type']."<BR/>";


$con = mysql_connect("********", "*************","************");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("*********", $con);

$sql="INSERT INTO videos (videoname, video, date)
VALUES
('$_POST[videoname]', '$new_file_name', '$mydate')";
if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "Video añadido";


mysql_close($con);

}
else
{
echo "Error no se cargo video";
}
}
?>
</body>
</html>

Link to comment
Share on other sites

I'm not sure where you got that example form but it is dated. $HTTP_POST_* has long ago been depricated. I'm surprised they are working at all. What version of php are you using? Use $_FILES instead.

 

Also, you should be using move_uploaded_file in place of copy.

 

I would start by fixing these things and seeing how you go.

Link to comment
Share on other sites

Firstly you should be using $_FILES and not $HTTP_POST_FILES.

 

Also, you should be using move_uploaded_file and not copy.

 

With that out of the way, please put this in your script (anywhere as long as a file would have been uploaded at that point):

echo '<pre>' . print_r($_FILES, true) . '</pre>';

Then post the output.

 

 

Link to comment
Share on other sites

Like I said, just put that code anywhere. For example here is the top of the code that you posted with that little snip added:

<html>
<body bgcolor="#FFFFFF">

<?php

$mydate = isset($_REQUEST["date5"]) ? $_REQUEST["date5"] : "";

echo '<pre>' . print_r($_FILES, true) . '</pre>';

 

EDIT: And the snippet will give you all of the information contained in the $_FILES array which may be useful for debugging, so please post the output here.

Link to comment
Share on other sites

I am getting

 

Array

(

)

 

Here is the updated script:

 

<html>
<body bgcolor="#FFFFFF">

<?php
$mydate = isset($_REQUEST["date5"]) ? $_REQUEST["date5"] : "";
echo '<pre>' . print_r($_FILES, true) . '</pre>';

// Your file name you are uploading
$file_name = $_FILES['video']['name'];
$file_type = $_FILES['video']['type'];




// random 4 digit to add to our file name
// some people use date and time in stead of random digit
$random_digit=rand(0000,9999);

//combine random digit to you file name to create new file name
//use dot (.) to combile these two variables

$new_file_name=$random_digit.$file_name;

//set where you want to store files
//in this example we keep file in folder upload
//$new_file_name = new upload file name
$path= "../videos/".$new_file_name;
if($ufile !=none)
{
if(move_uploaded_file($_FILES['video']['tmp_name'], $path))
{
echo "Video loaded<BR/>";

//$new_file_name = new file name
//$HTTP_POST_FILES['ufile']['size'] = file size
//$HTTP_POST_FILES['ufile']['type'] = type of file
echo "File Name :".$new_file_name."<BR/>";
echo "File Size :".$_FILES['video']['size']."<BR/>";
echo "File Type :".$_FILES['video']['type']."<BR/>";


$con = mysql_connect("*********", "*******","***********");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("*******", $con);

$sql="INSERT INTO videos (videoname, video, date)
VALUES
('$_POST[videoname]', '$new_file_name', '$mydate')";
if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "Video loaded";


mysql_close($con);

}
else
{
echo "Video not loaded";

}
}
?>
</body>
</html>

 

 

 

Link to comment
Share on other sites

If that output is after the form has been submitted, its likely that the size of the file exceeded the post_max_size setting (which causes both the $_POST and $_FILES arrays to be empty - http://www.php.net/manual/en/ini.core.php#ini.post-max-size ) or uploads are not enabled on your server or the form is invalid or the form does not have a type='file' input field. What size file did you attempt to upload?

Link to comment
Share on other sites

Good day:

 

What I did was enabled htaccess, and created an .htaccess file with the following code:

 

php_value upload_max_filesize 100M

php_value post_max_size 100M

php_value max_execution_time 6000

php_value max_input_time 6000

 

 

I know it seems overkill, but just wanted to make sure. Still, anything over 7MB gives me an empty array and does not upload. The upload form is multipart and works fine for anything under 8MB.

 

 

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.