• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 491
  • Last Modified:

File upload causing Page Cannot be displayed using php mysql


I am implemeting file upload to mysql as blob using php. When I select a file to upload and click submit (I am posting the form to SELF), IE shows "Page cannot be displayed" error message. When I refresh the page, the form works as expected and the file upload is successful.

I checked couple of forums and it indicated that the error might be related to configuration settings on apache. I tried those changes but not luck yet.

Here are those links:



There were few instances where the file upload worked fine but, now it keeps throwing error message.

Any directions in resolving this issue is highly appreciated.

1 Solution
Check the php.ini settings first:


If you have a slow upload speed (as many DSL and cable connections have), you could be timing out.

It is important to use the enctype="multipart/form-data" so that the browser uploads the binary data correctly.

<form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
            <input type="hidden" name="MAX_FILE_SIZE" value="10000000" />
            <input name="userfile[]" type="file" />
            <input type="submit" value="Submit" />

Is this on IE or Firefox, or both. IE is the best browser, never crashes of anything. ; )

Any process that involves extended data transfer over the web can get hung up, in my experience.

I would try submitting the form to a separate upload/processing page.
This page would (after upload event is finished) trigger a redirect that sends the user to either a results page or the original form page... along with feedback that file was successfully uploaded.

Sometimes breaking up the process over a couple different pages (http requests) can help the application/browser digest the process/rendering more easily.

Might be worth a try.
Let me know if that does/doesn't help.
Ludwig DiehlSystems ArchitectCommented:
try this. It works on IE and FF and sure it will work on almost any browser
        $uploadedFile  = $_FILES['file_upload']['name'];
        <form action="" enctype="multipart/form-data" method="POST">        
            <input type="hidden" name="MAX_FILE_SIZE" value="10000000000000000" />
            <input type="file" name="file_upload" />        
            <input type="submit" name="submit" value="Upload" />
            <br />
                    echo "Uploaded File: <span style=\"font-weight: bold;color: green;\">$uploadedFile</span>";
                    echo "<span style=\"color: red;font-weight:bold\">No File uploaded!</span>";

Open in new window

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

nalla_btsAuthor Commented:
@subscript - I included the upload script in another page (upload.php) and on form submit, I am posting it to upload.php.

At the end of file, I used header("Location: url ") but, no luck. If I refresh the page, it takes me to the html page and also the file upload is successful.

If I remove the header("Location: url), and use echo to display a message, it works and shows the message. Is this error because of header("Location: ") ?

nalla_btsAuthor Commented:
@gmckeown99 - I checked the values of upload_max_filesize and post_max_size. I set pretty high values to these config values and made sure than post_max_size > upload_max_size.

My form also has enctype="multipart/form-data". Just a reminder that file is uploaded successfully to the DB, but shows connection time out exception.

Fire Fox shows:

The connection was reset
The connection to the server was reset while the page was loading.
On the separate upload.php page...

Are you testing that the upload process is completed before attempting redirect?
ie. something like:

if ($file_is_uploaded) {
   /* redirect now */

If the header() redirect isn't working for some reason but echo is... you could consider using a Javascript redirect instead, such as:

if ($result) {
echo '
<SCRIPT language="JavaScript">

nalla_btsAuthor Commented:
I included the javascript redirection code but, no luck. But, when I give the redirect url as google.com, it works.

The page which I am redirecting to is a WordPress page? Does it have anything to do with WordPress?
nalla_btsAuthor Commented:
The issue is resolved:

I had mysql_close(); after I ran the sql query to insert the record into the DB. I am really unsure how closing the sql connection was causing the http connection to close.

It works on my local machine with mysql_close().

Huh. Well, without knowing all the details -- hard to say.

Happy you got it resolved anyway. Good luck to you!

Question PAQ'd, 500 points refunded, and stored in the solution database.

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now