Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_php thread: File Upload problem - x post with begining_php list


Message #1 by "Julie May" <jmay@s...> on Thu, 14 Mar 2002 14:23:09 -0700
Your "destination" string should be the path and filename where you want the
file moved to.

$dest_path = 'c:\\';  // whatever you want.

  ...

move_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'],
                   $dest_path . $HTTP_POST_FILES['userfile']['name']);



Try playing with this simple script and see if that doesn't help you figure
out what's going on.

----  uploadtest.php  ----
<html><head><title>Upload Test</title></head>
<body>

<pre>
<?php
  print_r($HTTP_POST_FILES);
?>
<hr />
<?php
  if( isset($HTTP_POST_FILES['userfile']) &&
($HTTP_POST_FILES['userfile']['name'] != ''))
  {
    echo "  Moving file...\n";
    move_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'],
                       "c:\\" . $HTTP_POST_FILES['userfile']['name']);
  }
  else
  {
    echo "  Nothing uploaded yet.\n");
  }
?>
<hr />
</pre>
<form enctype="multipart/form-data" action="uploadtest.php" method="post">
  <input type="hidden" name="MAX_FILE_SIZE" value="2048029">
  Send this file: <input name="userfile" type="file">
  <input type="submit" value="Send File">
</form>
</body>
</html>
-------------------------

nik


  Return to Index