Hey guys,

Basicly my nephew has just been born and I need to put soem images on my site for my grand parents (the great grad parents) to see.

I can upload smaller galleries and all is well but for some reason if I upload a larger archive, for example 54M this doesn't work.

I have added a php.ini file to the scripts directory that reads:

upload_max_filesize = 190M
post_max_size = 200M

However this doesn't effect it.

What happens is that when the archive is uploaded it is extracted the images are resized then put into a random string folder. Then the script is supposed to echo out a form that will add the gallery information to a Sql database. However when a large file is uploaded the script just goes dead.

I have heard of this before and I thought the post_max_size was supposed to resolve this, no?

Thanks in advance.

Script:

<?php



  if( isset( $_COOKIE['Username'] ) && $ui['Acc_Type'] == "adm" ) {

  ?>

	  <?php

	  if( !isset( $_GET['pro'] ) ) {

	  ?><h1>Add Gallery</h1>

	  

	  <p>To begin please upload a zip file containing all the images you wish to be in the gallery.</p>

	  

	  <form method="post" action="?pro=uploading" enctype="multipart/form-data">

	  

			 <label for="archive">Archive:</label>

			 <input type="file" name="file" id="file" />

			 <input type="submit" value="Upload" />

	  

	  </form>

	  <?php

	  }

	  if( $_GET['pro'] == "uploading" ) {

	   ?>

			<?php

			

			  if( !isset( $_FILES['file']['name'] ) ) {

				$err++;

				$cor .= '<li>You must select an archive to upload</li>';   

			  } else {

				$ext = explode( "." , $_FILES['file']['name'] );

				$count = 0;

				while( $ext[$count] == true ) {

					$count++;

				}

				$ext = $ext[$count-1];

				if( ( $ext != "zip" ) &&

				( $ext != "ZIP" ) ) {

					$err++;

					$cor .= '<li>Your archive must be in the correct zip format</li>';

				}

				

				if( $_FILES['file']['size'] / 1024 / 1024 > 75 ) {

					$err++;

					$cor .= '<li>Your file can\'t be more than 75MB</li>';

				}   

			  }

			  

			  if( $err > 0 ) {

				echo '<h1>Ooopsey errors...</h1>';

				echo '<ul>'.$cor.'</ul>';

				?>

				 <p>To begin please upload a zip file containing all the images you wish to be in the gallery.</p>

	  

				  <form method="post" action="?pro=uploading" enctype="multipart/form-data">

				  

						 <label for="file">Archive:</label>

						 <input type="file" name="file" id="file" />

						 <input type="submit" value="Upload" />

				  

				  </form>

				<?php  

			  } else {

				$code = sha1( time() . $ui['Username'] );

				@mkdir( "/home/exuhlno/public_joshconnerty/pictures/gallery/".$code."/" , 0755 );

				chmod( "/home/exuhlno/public_joshconnerty/pictures/gallery/".$code."/" , 0755 );

				@mkdir( "/home/exuhlno/public_joshconnerty/pictures/gallery/".$code."/large/" , 0755 );

				chmod( "/home/exuhlno/public_joshconnerty/pictures/gallery/".$code."/large/" , 0755 ); 

				if( @move_uploaded_file( $_FILES['file']['tmp_name'] , "/home/exuhlno/public_joshconnerty/pictures/gallery/".$code."/".$code.".".$ext ) ) {

					sql_con();

					$q = mysql_query("INSERT INTO galleries (id) VALUES ('$code')");

					extractZip( "/home/exuhlno/public_joshconnerty/pictures/gallery/$code/" , "$code.$ext" );

					unlink( "/home/exuhlno/public_joshconnerty/pictures/gallery/$code/$code.$ext" );

					//define the path as relative

					$path = "/home/exuhlno/public_joshconnerty/pictures/gallery/$code/";



					//using the opendir function

					$dir_handle = @opendir($path) or die("Unable to open $path");



					//running the while loop

					while ($file = readdir($dir_handle)) 

					{

					   if($file!="." && $file!="..") {

						  @resize( "/home/exuhlno/public_joshconnerty/pictures/gallery/$code/$file" , 500 , $path."large/".$file );

						  @resize( "/home/exuhlno/public_joshconnerty/pictures/gallery/$code/$file" , 80 , $path."$file" );

						  copy( "/home/exuhlno/public_joshconnerty/inc/editimages.php" , "/home/exuhlno/public_joshconnerty/pictures/gallery/$code/editimages.php" );

					   }

					}



					//closing the directory

					closedir($dir_handle);

					

					?>

					

						 <h1>Upload Successfull</h1>

						 

						 <p>Please edit the gallery details below.</p>

						 

						 <form method="post" action="checkGal.php" target="target">

						 

								<label for="name">Name:</label>

								<input type="text" name="name" id="name" />

								<input type="hidden" name="id" value="<?=$code?>" />

								

								<label for="desc">Description:</label>

								<textarea cols="30" rows="10" name="desc" id="desc"></textarea><br />

								

								Permissions:<br />

								<input type="checkbox" name="fri" value="1" />&nbsp;Friends<br />

								<input type="checkbox" name="fam" value="1" />&nbsp;Family<br />

								<span class="cont">

								<input type="checkbox" name="pub" value="1" onclick="makePublic();" />&nbsp;Public<br />

								</span>

								

								<input type="submit" value="Save" />

						 

						 </form>

						 

						 <div class="result"></div>

						 <iframe src="#" style="border: none;" name="target" id="target"></iframe>

						 

					

					<?php 



				}   

			  }

			

			?>

	   <?php   

	  }

	  

	  if( $_GET['pro'] == "savegal" ) {

		   

	  }

	  ?>

  <?php

  } else {

	restricted("Admin Control Panel");

  } 



?>

Recommended Answers

All 11 Replies

Do you get an error or does it just white-screen?

Also, remove all of the @#$% error suppression, it's slow and makes it hard as hell to debug.

White screen. As I say I have uploaded other archives that are of smaller size with no issue. This archive I'm trying to upload now is 114M :S.

And the @'s are from previous debuging.

A) use php -l <scriptname> to run PHP Lint to check for syntax errors
B) If you haven't already, remove the damn @ (error suppression)
C) Check your memory limit
D) If all else fails load the page, edit the script to die at one step, then upload and see if it still white-screens, repeat steps until it DOES whitescreen.

Okey dokw will do now.

Ahh just noticed, I didn't provide an error statement for the if(@move_uploaded_file

This might be why I get a blank screen.

EDIT: Just checking the upload again... Just so you know why I am not replying yet :D

no luck :(

Maybe it is a memory issue but don't you usually get error messages for that?

If it were a memory issue you'd get Allowed memory size of X blah blah, trying to allot X bites on line X. Make sure you have error_reporting turned on.

It seems to be a max execution time error. I got some other error messages as well for the image resizing but I always get these but they resize anyhow.

Just changed the max execution and input times to zero for now as that will give it unlimited and will allow me to find out if this is indeed the issue.

It seems to be a max execution time error. I got some other error messages as well for the image resizing but I always get these but they resize anyhow.

Just changed the max execution and input times to zero for now as that will give it unlimited and will allow me to find out if this is indeed the issue.

If it were a maximum execution time issue you would get "Maximum execution time of X exceeded by FILE. This is indeed a puzzling question.

No I did obviously I had suppresed a line out that was trying to tell me that. Just tested and, you are amazing, it indeed works.

Can see why you are much loved :P

Rep added and thankyou, you have been a great help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.