maxelcat
July 30th, 2007, 23:27
:?
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
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