note 19159 added to function.copy
| From: | julian at drault dot com dot ar | Date: | Mon, 18 Feb 2002 13:38:30 +0000 |
| Subject: | note 19159 added to function.copy | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-26740@lists.php.net to get a copy of this message | ||
// The easiest way to upload/copy a file to the server
<HTML>
<TITLE>
File upload
</title>
<body>
<B>File upload</b><BR><BR>
<form enctype="multipart/form-data" action="<?PHP echo $PHP_SELF ?>"
method="post">
<!-- "MAX_FILE_SIZE" determines the biggest size an uploaded file can occupy -->
<input type="hidden" name="MAX_FILE_SIZE" value="500000">
Send this file:
<input name="userfile" type="file">
<input type="submit" name="submit" value="Send File">
</form>
</body>
<?PHP
/*
$userfile - The temporary filename in which the uploaded file was stored on the server machine.
$userfile_name - The original name or path of the file on the sender's system.
$userfile_size - The size of the uploaded file in bytes.
$userfile_type - The mime type of the file if the browser provided this information. An example
would be "image/gif".
*/
// copy to this directory
$dir="./bor/";
// copy the file to the server
if (isset($submit)){
copy($userfile,$dir.$userfile_name);
if (!is_uploaded_file ($userfile)){
echo "<BR> <b>$userfile_name</b> couldn't be copied !!";
}
}
// check whether it has been uploaded
if (is_uploaded_file ($userfile)){
echo "<BR> <b>$userfile_name</b> copied succesfully !!";
}
?>
</html>
--
http://www.php.net/manual/en/function.copy.php
http://master.php.net/manage/user-notes.php?action=edit+19159
http://master.php.net/manage/user-notes.php?action=delete+19159
http://master.php.net/manage/user-notes.php?action=reject+19159