Jump to content

very simple test for file field - doesn't word


maxelct

Recommended Posts

Dear All

 

:(

 

I have what I think is a very simple piece of code.

 


<?php

if (isset($_POST['submitted'])){

if(!isset($_FILES['upload'])){
	echo '<br />a file was selected';
	}else{
	echo '<br />a file was not selected';
	}



}//end of submitted

?>


<form enctype="multipart/form-data" action="upload_test.php" method="post">

<input type="hidden" name="MAX_FILE_SIZE" value="16000000" />
<fieldset><legend>Select a File</legend>
<input type="file" name="upload" />
</fieldset>
<input type="submit" name="submit" value="submit me" />
<input type="hidden" name="submitted" value="TRUE" />
</form>
:
:

I want a simple test for if the user has picked a file or not. I figured that if(isset$_files['upload']){....}else{...} might be a good one but it doesn't work.

 

If you have no file selected and press submit then you get "No file selected". If you then select a file and press submit you sill get no file selected. Worse, if you then re-load the page, select a file and press submit you STILL get "No file selected"

 

I expect I am doing something stupid here...

 

can someone please advise!

 

Thanks

 

Edward

m

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.