Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

upload large files

Status
Not open for further replies.

neisye

Programmer
Mar 5, 2008
11
AU
am trying to upload movie files of about 50m to my website

this is my php ini file settings ---
upload_max_filesize 100M 100M
max_execution_time 200 200
max_input_time 200 200
memory_limit 256M 256M
session.gc_maxlifetime 10800 10800


the file uploads with no problem to the temp file as follows

Client Filename: archiform3d-animation-coconut-grove.mov
File Type: video/quicktime
File Size: 7922.1484375 Kb
Name of Temporary File: /tmp/phpNzeVaZ

i just cant move it from the temp folder been trying all day
and get this warning

Warning: move_uploaded_file(/tmp/phpNzeVaZ): failed to open stream: No such file or directory in /hsphere/local/home/archifor/archiform3d.com/upload.php on line 132 Warning: move_uploaded_file(): Unable to move '/tmp/phpNzeVaZ' to 'archif_video/32.mov' in /hsphere/local/home/archifor/archiform3d.com/upload.php on line 132


where am i going wrong???
thank you
 
8000Kb does not look much like 50MB. you have not got the whole file uploaded. this is equally likely to be a browser issue.

and you have not posted the code that you are using for move_uploaded_file.
 
hey
that was actually an 8000kb file i was uploading so i had the whole file uploaded.

heres the code

Code:
<?php
//require_once("unameProtection.php");//check log in status
// Include the database details, and make a connection
require_once("checklogin_code.php");//check log in status	
include "../archif_login/archif_details.php";	

	
// initialization
	@session_start();
	$result_final = "";
	$counter = 0;
	$video = $_GET['video'];
	ini_set('session.gc_maxlifetime', '200000');
	
	//date
	 $date = date("Y-m-d") ;
     $dateArray=explode("-",$date);
     $aust_format= $dateArray[2] ."-". $dateArray[1]."-". $dateArray[0] ;
//watermarkimg
	$watermark_dir="defaultimgs/watermark_logo.jpg";
	$watermark_opacity=30;
if(isset($_GET['video'])){

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

$extension = "ffmpeg";
$extension_soname = $extension . "." . PHP_SHLIB_SUFFIX;
$extension_fullname = PHP_EXTENSION_DIR . "/" . $extension_soname;

// load extension
if (!extension_loaded($extension)) {

dl($extension_soname) or die("Can't load extension $extension_fullname\n");

}


/*****************Get the path to Extention ****************/


$array_path = explode("/",$_SERVER['SCRIPT_FILENAME']);
$dynamic_path = "";
for ($i=0;$i<sizeof($array_path)-1;$i++)
if($array_path[$i]!="")
$dynamic_path =$dynamic_path."/".$array_path[$i];

//echo "path=".$dynamic_path."<br/>";// exit;

/******************set folders*****************************/

$flvpath   = "archif_video_flv/";
$moviepath = "archif_video/";

/******************Upload and convert video *****************************/


$fileName = $_FILES["x_URL"]["name"];
$fileNameParts = explode( ".", $fileName );
$fileExtension = end( $fileNameParts );
$fileExtension = strtolower( $fileExtension );


if(isset($_FILES["x_URL"]))

{

echo "<table border=\"1\">";
echo "<tr><td>Client Filename: </td>
   <td>" . $_FILES["x_URL"]["name"] . "</td></tr>";
echo "<tr><td>File Type: </td>
   <td>" . $_FILES["x_URL"]["type"] . "</td></tr>";
echo "<tr><td>File Size: </td>
   <td>" . ($_FILES["x_URL"]["size"] / 1024) . " Kb</td></tr>";
echo "<tr><td>Name of Temporary File: </td>
   <td>" . $_FILES["x_URL"]["tmp_name"] . "</td></tr>";
echo "</table>";



if($fileExtension=="avi" || $fileExtension=="wmv" || $fileExtension=="mpeg" || $fileExtension=="mpg" || $fileExtension=="mov" || $_FILES["x_URL"]["size"] > 0 ){


mysql_query( "INSERT INTO archif_video(`archif_filename`, `archif_caption`, `archif_category`) VALUES('0', '".addslashes($photo_caption[$counter])."', '".addslashes($_POST['category'])."')" );


$new_id = mysql_insert_id();
$filename = $new_id.".".$fileExtension;			

mysql_query( "UPDATE archif_video SET archif_filename='".addslashes($filename)."' WHERE archif_id='".addslashes($new_id)."'" );

if ( move_uploaded_file($_FILES["x_URL"]["tmp_name"],$moviepath.$filename)){ ....
 
are you sure that there is a directory called archif_video/ as a subdirectory of the cwd?
 
yes am sure. whats happening is that this code works when it wants to with files less than 2m after about 10 tries and the file is actually moved to the archif_video/ subdirectory form the temp file.
files less than 100m are uploaded in the temp file but just wont be moved.

i have changed move_uploaded_file() to copy() and now i get only one warning below

Client Filename: keybiscayne-3danimation.wmv
File Type: video/x-ms-wmv
File Size: 4226.43457031 Kb
Name of Temporary File: /tmp/phpe3j0AU

Warning: copy(/tmp/phpe3j0AU): failed to open stream: No such file or directory in /hsphere/local/home/archifor/archiform3d.com/upload.php on
line 134

been trying all day long.???
thanks
 
please insert the following code on your receiving script and post the result

Code:
echo "<pre>".print_r($_FILES, true) . "</pre>";
 
done that here is the result

Array
(
[x_URL] => Array
(
[name] => 18.mov
[type] => video/quicktime
[tmp_name] => /tmp/phpI61l1f
[error] => 0
[size] => 2053514
)

)



Client Filename: 18.mov
File Type: video/quicktime
File Size: 2005.38476562 Kb
Name of Temporary File: /tmp/phpI61l1f

Warning: move_uploaded_file(/tmp/phpI61l1f): failed to open stream: No such file or directory in /hsphere/local/home/archifor/archiform3d.com/upload.php on line 140 Warning: move_uploaded_file(): Unable to move '/tmp/phpI61l1f' to 'archif_video/56.mov' in /hsphere/local/home/archifor/archiform3d.com/upload.php on line 140



Code:
<?php
	
	//require_once("unameProtection.php");//check log in status
// Include the database details, and make a connection
require_once("checklogin_code.php");//check log in status	
include "../archif_login/archif_details.php";	


	
	
			// initialization
		@session_start();
	$result_final = "";
	$counter = 0;
	$video = $_GET['video'];
	
	
	
	//ini_set('session.gc_maxlifetime', '200000');
	
	
	
	//date
	 $date = date("Y-m-d") ;
     $dateArray=explode("-",$date);
     $aust_format= $dateArray[2] ."-". $dateArray[1]."-". $dateArray[0] ;
//watermarkimg
	$watermark_dir="defaultimgs/watermark_logo.jpg";
	$watermark_opacity=30;
	
	
	
	

if(isset($_GET['video'])){

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////







$extension = "ffmpeg";

$extension_soname = $extension . "." . PHP_SHLIB_SUFFIX;

$extension_fullname = PHP_EXTENSION_DIR . "/" . $extension_soname;



// load extension

if (!extension_loaded($extension)) {

dl($extension_soname) or die("Can't load extension $extension_fullname\n");

}


/*****************Get the path to Extention ****************/


$array_path = explode("/",$_SERVER['SCRIPT_FILENAME']);

$dynamic_path = "";

for ($i=0;$i<sizeof($array_path)-1;$i++)

if($array_path[$i]!="")

$dynamic_path =$dynamic_path."/".$array_path[$i];

//echo "path=".$dynamic_path."<br/>";// exit;


/******************set folders*****************************/

$flvpath   = "archif_video_flv/";

$moviepath = "archif_video/";


/******************Upload and convert video *****************************/

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

echo "<table border=\"1\">";
echo "<tr><td>Client Filename: </td>
   <td>" . $_FILES["x_URL"]["name"] . "</td></tr>";
echo "<tr><td>File Type: </td>
   <td>" . $_FILES["x_URL"]["type"] . "</td></tr>";
echo "<tr><td>File Size: </td>
   <td>" . ($_FILES["x_URL"]["size"] / 1024) . " Kb</td></tr>";
echo "<tr><td>Name of Temporary File: </td>
   <td>" . $_FILES["x_URL"]["tmp_name"] . "</td></tr>";
echo "</table>";


$fileName = $_FILES["x_URL"]["name"];

$fileNameParts = explode( ".", $fileName );

$fileExtension = end( $fileNameParts );

$fileExtension = strtolower( $fileExtension );






if(isset($_FILES["x_URL"]))


{





if($fileExtension=="avi" || $fileExtension=="wmv" || $fileExtension=="mpeg" || $fileExtension=="mpg" || $fileExtension=="mov" || $_FILES["x_URL"]["size"] > 0 ){


mysql_query( "INSERT INTO archif_video(`archif_filename`, `archif_caption`, `archif_category`) VALUES('0', '".addslashes($photo_caption[$counter])."', '".addslashes($_POST['category'])."')" );


				$new_id = mysql_insert_id();
				$filename = $new_id.".".$fileExtension;
				

mysql_query( "UPDATE archif_video SET archif_filename='".addslashes($filename)."' WHERE archif_id='".addslashes($new_id)."'" );





//if ( copy($_FILES["x_URL"]["tmp_name"],$moviepath.$filename)){
if (move_uploaded_file($_FILES["x_URL"]["tmp_name"],$moviepath.$filename)){


if( $fileExtension == "wmv" ) {

//exec("rm -rf ".$dynamic_path."/".$flvpath."myflv.flv");

exec("ffmpeg -i ".$dynamic_path."/".$moviepath."".$fileName." -sameq -acodec libmp3lame -ar 22050 -ab 32 -f flv -s 320x240 ".$dynamic_path."/".$flvpath."myflv.flv");

$result_final .= "WMV file Converted.<br/><br/>";

}





if( $fileExtension == "avi" || $fileExtension == "mpg" || $fileExtension == "mpeg" || $fileExtension == "mov" ) {





$result_final .= "<br/> <a href='viewfiles.php?video=01010101&categoryid=".$cat."&amp;photoid=".$new_id."'>  <img src='archif_video_flv/".$new_id.".png' border='0' alt='Video uploaded' height='70' width='70'/>  </a><br/>";

//exec("ffmpeg -i ".$dynamic_path."/".$moviepath."".$filename." -sameq -acodec libmp3lame -ar 22050 -ab 32 -f flv -s 320x240 ".$dynamic_path."/".$flvpath."myflv.flv");

exec("ffmpeg -i ".$dynamic_path."/".$moviepath."".$filename." -sameq  -ar 22050 -ab 32 -f flv -s 320x240 ".$dynamic_path."/".$flvpath.$new_id.".flv");


$result_final .= "File successfully converted .<br/><br/>";
}






/******************create thumbnail***************/
exec("ffmpeg -y -i ".$dynamic_path."/".$moviepath."".$filename." -vframes 1 -ss 00:00:03 -an -vcodec png -f rawvideo -s 320x240 ".$dynamic_path."/".$flvpath.$new_id.".png");








}

else

{

$result_final .="The file was not uploaded.<br/><br/>";

}

}



else

{

$result_final .="Please upload files only with avi, wmv, mov or mpg extension!<br/><br/>";

}

}


else


{


$result_final .="File not found on host machine<br/><br/>";


}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

}
 
are you using sessions to manage access?

if so, what is your session.gc.maxlifetime set to?

and try stipulating a destination path using getcwd().
Code:
$cwd = getcwd();
if (  move_uploaded_file($_FILES["x_URL"]["tmp_name"],
       $cwd . PATH_SEPARATOR . $moviepath . $filename)  ){
//do something
] else {
 //complain
}
 
let me rephrase to make things simpler rather than talk about garbage collection.

disable the user/login management and see whether things work properly.
 

i have simplified the code with no log in management

session.gc.maxlifetime = 10800

---form----
Code:
	<form action="upload_w_u.php" method="post" enctype="multipart/form-data">
         <table style="width: 90%;" align="center" border="0" width="90%">
		 
		 
		    <tbody>

             
              <td width="120"><strong>Choose a Video to upload:</strong></td>
			  </tr>
			  <tr>
              <td width="242">
			  
			  <input name="x_URL" type="file">
			  <input name="category" value="" type="hidden">
			   
			  </td>
            </tr>

            <tr>
              <td align="center"><input name="sendForm" value="Add Video" type="submit"><br>
			  
			 </td>
            </tr>
           
          </tbody></table>
        </form>
---php-----
Code:
/******************set folders*****************************/

$flvpath   = "archif_video_flv/";
$moviepath = "archif_video/";

$cwd = getcwd();
//echo $cwd."<br/>";

/******************Upload and convert video *****************************/

echo "<pre>".print_r($_FILES, true) . "</pre><br/>";
$fileName = $_FILES["x_URL"]["name"];
$fileNameParts = explode( ".", $fileName );
$fileExtension = end( $fileNameParts );
$fileExtension = strtolower( $fileExtension );

if(isset($_FILES["x_URL"])){

           //if ( copy($_FILES["x_URL"]["tmp_name"],$moviepath.$filename)){
        if (move_uploaded_file($_FILES["x_URL"]["tmp_name"],$cwd."/".$moviepath.$fileName)){
                  echo "The file was  uploaded.<br/><br/>";
             }else{
                  echo "<br/> file not uploaded<br/><br/>";
                    }
}


all files upload wether big or small but only the ones less than 2m are moved to the archif_video folder ????????

not moved

Array
(
[x_URL] => Array
(
[name] => 595corp-video-production-A.mov
[type] => video/quicktime
[tmp_name] => /tmp/phpsI673j
[error] => 0
[size] => 13483444
)

)


Warning: move_uploaded_file(/tmp/phpsI673j): failed to open stream: No such file or directory in /hsphere/local/home/archifor/archiform3d.com/upload_w_u.php on line 24 Warning: move_uploaded_file(): Unable to move '/tmp/phpsI673j' to '/hsphere/local/home/archifor/archiform3d.com/archif_video/595corp-video-production-A.mov' in /hsphere/local/home/archifor/archiform3d.com/upload_w_u.php on line 24
file not uploaded



successfully moved

Array
(
[x_URL] => Array
(
[name] => DWPI B liv stillA1.jpg
[type] => image/jpeg
[tmp_name] => /tmp/php4Evh3L
[error] => 0
[size] => 2266408
)

)


file moved to archif_video folder
 
are you able to move the file using a file system command through exec() or similar?
 
yes am able to move the files from the archif_video using exe()
 
I think your are missing a max_post_size or something like that. Read "uploading files" in the PHP documentation. It tells you all you need to know.

+++ Despite being wrong in every important aspect, that is a very good analogy +++
Hex (in Darwin's Watch)
 
max_post_size is not a mandatory requirement.

there is something else going wrong - time outs or somesuch. possibly even a corrupted php installation.
 
What exactly do you mean by that?

There is a hidden field that may be ignored, but I was talking about the INI setting that limits the post size. PHP will certainly respect that.

+++ Despite being wrong in every important aspect, that is a very good analogy +++
Hex (in Darwin's Watch)
 
my apologies. i assumed incorrectly that you were not referring to the ini settings
 
don't know if its about timing out. it works ok with smaller files less than 2m but sends warnings with large files that wont be moved from the /temp folder.
 
solved!!!

changed the temp folder to upload_tmp_dir ---- /tmp/up ---and its working

thanks anyway
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top