max power: Datei hochladen

Beitrag lesen

ein einfaches beispiel sieht ungefähr so aus:

HTML teil:

<form enctype="multipart/form-data" action="upload_go.php"
method="post"> <INPUT TYPE="hidden" name="MAX_FILE_SIZE"
value="100000">

<td>file: </td>
   <td><input type="File" name="userfile" size="30" maxlength="255">
</td>
   <td colspan="2" align="center">
   <INPUT TYPE="submit" VALUE="upload">
   </td>

PHP teil

<?php

function upload_file()
{
global $target_dir,$target_file;
   // contains full path to uploaded file in temprary storage
   $upload_temp = $_FILES['userfile']['tmp_name'];
   // get file name portion of source file
   $upload_file = $_FILES['userfile']['name'];
   // destination directory for uploaded file
   $target_dir = "Z:\MartiniPSSForms\uploads";
   // build target filename
   $target_file = $target_dir . "\" . $upload_file;

// try to copy file to real upload directory
   if (!copy($upload_temp, $target_file))
   {
   echo "<h4>Failed to copy file...<h4><br>\n";
   return;
   }
}

?>

<?php
upload_file();
?>