note 83660 added to function.copy
| From: | zeusakm at gmail dot com | Date: | Fri, 06 Jun 2008 08:50:45 +0000 |
| Subject: | note 83660 added to function.copy | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-140171@lists.php.net to get a copy of this message | ||
[php]
<?
//file_upload.php
$archive_dir = "/Inetpub/wwwroot/beginning_php5/ch07/docs";
function upload_form() {
global $PHP_SELF;
?>
<form method="POST" enctype="multipart/form-data" action="<? echo
$PHP_SELF ?>">
<input type="hidden" name="action" value="upload">
Upload file!
<input type="file" name="userfile">
<input type="submit" name="submit" value="upload">
</form>
<?
}
function upload_file() {
global $userfile, $userfile_name, $userfile_size,
$userfile_type, $archive_dir, $WINDIR;
if(isset($WINDIR)) $userfile = str_replace("\\\\","\\", $userfile);
$filename = basename($userfile_name);
if($userfile_size <= 0) die ("$filename is empty.");
if(!@copy($userfile, "$archive_dir/$filename"))
die("Can't copy $userfile_name to $filename.");
if(isset($WINDIR) && !@unlink($userfile))
die ("Can't delete the file $userfile_name.");
echo "$filename has been successfully uploaded.<br>";
echo "Filesize: " . number_format($userfile_size) . "<br>";
echo "Filetype: $userfile_type<br/>";
}
?>
<html>
<head><title>file upload</title></head>
<body>
<?
if($action == 'upload')
{
upload_file();
} else {
upload_form();
}
?>
</body>
</html>
[/php]
----
Server IP: 195.54.192.44
Probable Submitter: 127.0.0.1
----
Manual Page -- http://www.php.net/manual/en/function.copy.php
Edit -- https://master.php.net/note/edit/83660
Del: integrated -- https://master.php.net/note/delete/83660/integrated
Del: useless -- https://master.php.net/note/delete/83660/useless
Del: bad code -- https://master.php.net/note/delete/83660/bad+code
Del: spam -- https://master.php.net/note/delete/83660/spam
Del: non-english -- https://master.php.net/note/delete/83660/non-english
Del: in docs -- https://master.php.net/note/delete/83660/in+docs
Del: other reasons-- https://master.php.net/note/delete/83660
Reject -- https://master.php.net/note/reject/83660
Search -- https://master.php.net/manage/user-notes.php