Header("Location: not working in IE?

I have a page that uploads files then redirects the user to another page after the files upload, everything works fine in every browser except Internet Explorer. Does anyone have any idea why? Here is part of the code:

<?php
require 'config.php';
if (isset($_POST['upload']) && $_POST['upload'] == 1) {
	procUpload();
} elseif (isset($_POST['detail']) && $_POST['detail'] == 1) {
	procDetail();
} else {
	header("Location: ../../index.php");
	die();
}

function procUpload()
{
	// Disable PHP Timeout example
	// http://php.snippetdb.com
	
	//set php script timeout, 0 to disable
	set_time_limit(0); 

	$post = $_POST;
	$num_images = $post['uploader_count'];

	if (strlen($post['order_id'])>0) {
		$path = $post['order_id'];
	} else {
		$no_spaces = str_replace(" ", "_", $post['name']);
		$path = $no_spaces;
	}

	$date = date('m-d-y');

	for ($i=0;$i<$num_images;$i++) {
		$imageSet[$i]['tmpname'] = $post['uploader_'.$i.'_tmpname'];
		$imageSet[$i]['name'] = $post['uploader_'.$i.'_name'];
		$imageSet[$i]['status'] = $post['uploader_'.$i.'_status'];
	}

	$new_file = "";
	$file_temp = "";
	$upload_dir = "/ClientUploads/".$path."/".$date."/";
	$newImagePaths = array();

	$i=0;
	foreach ($imageSet as $iS) {
		$curTime = time();

		$file_temp=TARGET_DIRECTORY.$iS['tmpname'];

		$new_file=TARGET_DIRECTORY.$curTime."-".$iS['name'];

		$newImagePaths[] = RELATIVE_DIRECTORY.$curTime."-".$iS['name'];
		$fullImagePaths[] = $new_file;

		rename($file_temp, $new_file);

		// Upload
		//        $uploader = new DropboxUploader($_POST['email'], $_POST['password']);
		$uploader = new DropboxUploader(DROPBOX_EMAIL, DROPBOX_PASSWORD);
		//        $uploader->upload($tmpFile, $_POST['dest']);
		$uploader->upload($new_file, $upload_dir);

		//        unlink($new_file);
		$i++;
	}

	$_SESSION['step1'] = $post;
	$_SESSION['step1']['newImagePath'] = $newImagePaths;
	$_SESSION['step1']['dropboxPath'] = $upload_dir;
	
	//don't forget to reset to 30 seconds.
	set_time_limit(30); 
	
	header("Location: http://example.com/upload/detail/");
	die();
	

}

When a user uploads through IE it redirects them to a white page instead of example.com/upload/detail/ as I have near the bottom:

header("Location: http://example.com/upload/detail/");
	die();

I’m not sure what to do I’ve moved

header("Location: http://example.com/upload/detail/");
	die();

to line 3 and it redirects fine (except the rest of the PHP code doesnt execute), anything lower than that and it doesn’t work.

Any ideas?

Thanks

hmmm…strange.

what is the url displayed in the browser’s navigation bar for this white page?

The URL being displayed is the page that contains the code I’ve included in the original post.

Here’s how it works, a user visits /upload/index.php they upload files and it sends them to /detail/index.php –> the redirect to details is when the white page happens and the URL displays /upload/inc/assets/process.php –> this is the page in which I’ve included the above code so I’m assuming something on this page is breaking in IE.

Actually… Here’s a video of it in action: http://screencast.com/t/HqG0W8U0

ok, I sort of understand what it is doing.

but it looks like you just need to do some basic debugging.

this is what I nomally do in situations like this.

  1. start at the top of the script as specified in your form’s action attribute and add

echo 'got here'; die();

  1. run your form to check if it gets to your php script

  2. then move the above echo/die down, line by line if you have to, and add appropriate echo statements to display values of variables and then run the form again each time you move the echos.

  3. as part of 3) insert the echos in each part of conditional blocks (IF blocks) to check your code logic is correct

keep doing this until your echos show something is not right. then back track your code to fix the error.

  1. keep repeating 3) and 4) until you get to the end of your script and it works ok.

if you have a debugger, then debugguing will be easier as you can set break points and check values of variables which is essentially what the above steps are doing.

Thanks for the help. I was able to find 1 line that is causing the problem… When I place echo ‘got here’; die(); before

$uploader->upload($new_file, $upload_dir);

it displays “got here”, when I place it after that line it breaks.

However, I don’t see anything wrong with that line. Any ideas on what would cause it to break and only in Internet Explorer? It still seems to be working fine in FireFox.

$new_file = "";
	$file_temp = "";
	$upload_dir = "/ClientUploads/".$path."/".$date."/";
	$newImagePaths = array();

	$i=0;
	foreach ($imageSet as $iS) {
		$curTime = time();

		$file_temp=TARGET_DIRECTORY.$iS['tmpname'];

		$new_file=TARGET_DIRECTORY.$curTime."-".$iS['name'];

		$newImagePaths[] = RELATIVE_DIRECTORY.$curTime."-".$iS['name'];
		$fullImagePaths[] = $new_file;

		rename($file_temp, $new_file);

		// Upload
		//        $uploader = new DropboxUploader($_POST['email'], $_POST['password']);
		$uploader = new DropboxUploader(DROPBOX_EMAIL, DROPBOX_PASSWORD);
		
		//        $uploader->upload($tmpFile, $_POST['dest']);
		$uploader->upload($new_file, $upload_dir);
		//        unlink($new_file);
		$i++;
	}

did you use the same debugging process to find at which line it is breaking in IE?

and if so, which line it it?

The test I mentioned above is in IE, everything works fine in every other browser except IE.

This is the line that is breaking in IE:

$uploader->upload($new_file, $upload_dir);