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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File does not upload

Status
Not open for further replies.

ascikey

Programmer
Feb 18, 2004
127
GB
I am messing with file uploads from a book (PHP for the world wide web, Larry Ullman) and I have tried the following script but no file us uploaded and I get a page cannot be displayed error. Any ideas as to why this is happening, the script is in a file called uploadFile.php.

Code:
<html>
<head>
<title>Upload Boat Details</title>
</head>
<body>
<?php
//decide weather 2 handle form
if (isset($_POST['file']))
{
  $file1 = $_POST['file'];
  print ("file name: $file_name<p>\n");
  print ("file size: $file_size<p>\n");
  if (copy($file1, "user/$file_name"))
  {
      print ("your file was successfully uploaded<p>\n");
  }else{
      print ("your file could not be copied<p>\n");
  }
  unlink($file);
}

print ("upload a file to the sever:\n");

print ("<form action=\"uploadFile.php\" method=POST ENCTYPE=\"multipart/form-data\">\n");

print ("file  :<input type=file name=\"file\" size=20><br>\n");

print ("<input type=submit name=\"submit\" value=\"submit\"></form>\n");    

?>
</body>
</html>

thx
 
It looks like the example from the book expects your PHP installation to have the configuration directive register_globals set to "on".

Have you examined the contents of the $_FILES superglobal array?

I recommend you read the PHP online manual section on Handling file uploads

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
thanks for your recommendation it looks like what i need and i will let you know how i go on.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top