Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

file upload

Status
Not open for further replies.

ThomasJSmart

Programmer
Joined
Sep 16, 2002
Messages
634
what is wrong with this script cuz i cant see it :-(


Code:
<html>
<head>
<title>test</title>
</head>

<body>

<?
if (isset($_POST['pic']))
{
global $_FILES; 
echo $_FILES['pic']['name'];
echo &quot;test&quot;;
}
?>

<form action=&quot;&quot; method=&quot;post&quot; enctype=&quot;multipart/form-data&quot; name=&quot;form1&quot;>
  <input type=&quot;file&quot; name=&quot;file&quot;>
  <input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;Submit&quot;>
</form>

</body>
</html>

what happens is i open a pic with the file browser, then press submit, the screen flashes and nothing else happens. (i can still see the input field & button) i cant see the filename, or &quot;test&quot;

also if i test the file adding a get var ( the get var stays in the url address after i press submit, im sure this isnt right....

cheers,
thomas

I learned a bit yesterday, today i learned a lot, imagine what i'll learn tomorrow!
 
if you dont fill anything in it uses _self

but iv put the doc name in the action, it still doesnt work, altho it now removes the foo=bar get var from the url address when i submit

I learned a bit yesterday, today i learned a lot, imagine what i'll learn tomorrow!
 
Not if you set the action to blank. Maybe if you don't set that attribute at all.

So, this script is supposed to output HTML which will submit back to itself? I notice that you have an if statement which references $_POST['pic']. Where does that HTML form element appear in your HTML output?



Want the best answers? Ask the best questions: TANSTAAFL!!
 
hehe oeps.... of course, the file thing isnt a $_POST['pic'] its a $_FILE

:S sorry to waist your time, i should have thought of that, changed $_POST['pic'] to $_POST['Submit'] and it works fine.

cheers

I learned a bit yesterday, today i learned a lot, imagine what i'll learn tomorrow!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top