Page 1 of 1

File Upload - various problems

Posted: Thu Aug 02, 2012 2:32 pm
by kezza
Hi,
Thanks for tutorials find them a great pace and full of useful stuff. however having some problems with the file upload tutorial. I don't think it is down to my code. I had put in all of the if(isset($_FILES ........... move_uploaded_file etc etc etc. However although the form displays fine, everytime I pressed the submit button, the browser went to an 'Internet Explorer cannot display this page' error. To try and see where it was going wrong I stripped code back and just did a print_r($_FILES) in the php section at top of page to check it was getting there but same error (also occurs in Chrome). I then got rid of the PHP section altogether and error continued. Therefore it seems as soon as I put an input with type file it fails on my computer.

If I do the same thing using text inputs and then use a print_r($_POST) this works fine so the problem seems to be around the file input.

Any help would be great. I am a teacher and trying to learn php for use in school.

Thanks

Re: File Upload - various problems

Posted: Fri Aug 03, 2012 8:26 am
by Helx
(Ew, Internet Explorer)

I usually get errors like that when code blocks aren't closed off.
Like: if(isset($_POST){ echo "Llama"; }
(You'll notice that "isset" isn't closed off)

If you want more in-depth help, post ALL of the code you have, or the problematic lines.

Re: File Upload - various problems

Posted: Fri Aug 03, 2012 3:54 pm
by kezza
Thanks. However the problem i am pretty sure is not with the HTML or PHP code. I think it must be to do with settings somewhere as not working on IE or Chrome. Any help would be great if any ideas. thanks
<?php
//print_r($_POST);
//print_r($_FILES);
?>
<!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 content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Forms</title>
</head>

<body>
<form action="" method="post" enctype="multipart/form-data">
<p>
	<input type="text" name="text_input" />
</p>
<p>
	<input type="file" name="upload"/>
</p>
<p>
	<input type="submit" value="Send"/>
</p>
</form>
</body>

</html>

Re: File Upload - various problems

Posted: Fri Aug 03, 2012 10:24 pm
by jacek
It sounds like a problem with your server :? Does it work with a normal form instead of a file upload one ?