homepage Welcome to WebmasterWorld Guest from 54.235.36.164
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Large Upload = Blank Screen
IntegrityWebDev




msg:4282942
 1:59 pm on Mar 17, 2011 (gmt 0)

I am trying to do a large file upload using PHP. I have the upload working with files I've tested up to 85MB. The files upload successfully but the problem is the page comes back "blank".

Here is what I've put in the php 4.9 INI file:
upload_max_filesize = 200M
post_max_size = 200M
memory_limit = 240M
max_execution_time = "300"
max_input_time = "300"


On the last 2 fields I've changed those to 3000 but I dont think they take effect until the GoDaddy servers pick them up later on.

The script is working and if I view source on the "blank" page I can see the HTML for the page there...but the page is just coming back blank.

Here is the source:
<?php
set_time_limit(0);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?
if($_SERVER['REQUEST_METHOD'] == "POST")
{
$target_path = "somedirectory/";

$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
}
?>
<form enctype="multipart/form-data" action="index.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="10000000000000" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>
</body>
</html>


I've tested 1 to 20mb files and they upload fine and get the page contents.

Any thoughts?

Thanks,
Chris

 

Matthew1980




msg:4283018
 3:16 pm on Mar 17, 2011 (gmt 0)

Hi there IntegrityWebDev,

<?
if($_SERVER['REQUEST_METHOD'] == "POST")


Just something that jumped off the screen to me, always use the correct tags when declaring a php document - this can cause all sorts of error's.

SO:-

<?php
if($_SERVER['REQUEST_METHOD'] == "POST")


would be best.

Cheers,
MRb

IntegrityWebDev




msg:4283030
 3:31 pm on Mar 17, 2011 (gmt 0)

Hey Mathew, you are right! I broke one of my own cardinal rules there. :-) I just did a test and it seemed to work. I will test with a larger file and post back if there are any problems. ...it's always the little thing.... ;-)

rocknbil




msg:4283075
 4:06 pm on Mar 17, 2011 (gmt 0)

Your PHP limits may not be enough, the browser may be timing out on the connection. I like to use fork() for such huge data transfers (and other time intensive tasks), this allows you to fork the upload itself as a background process and return an immediate response to the browser.

IntegrityWebDev




msg:4283238
 7:59 pm on Mar 17, 2011 (gmt 0)

Fork looks good but I need the file uploaded first so I can query the file for some info I need to put into a DB and immediately display on the screen.

IntegrityWebDev




msg:4283244
 8:07 pm on Mar 17, 2011 (gmt 0)

Just tried an 85mb file and the page died (page does not exist after a while)...so it doesn't look like I have it beat yet.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved