FILE UPLOAD Q
| From: | nabil | Date: | Sun, 08 Jun 2003 07:07:02 +0000 |
| Subject: | FILE UPLOAD Q | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-150647@lists.php.net to get a copy of this message | ||
Please help me , I want to make any user on my website to submit his CV , or
any file to a temp folder, the following script create a "fupload" file ,
and I don't want to dump the original in it, I want to upload the file as it
is, with its extension...
by example
////
<html>
<head>
<title>Listing 9.14 A file upload script</title>
</head>
<?php
$file_dir = "C:\\Inetpub\\wwwroot\\temps\\uploads";
$file_url = "http://localhost/temps\uploads";
foreach( $HTTP_POST_FILES as $file_name => $file_array ) {
print "path: ".$file_array['tmp_name']."<br>\n";
print "name: ".$file_array['name']."<br>\n";
print "type: ".$file_array['type']."<br>\n";
print "size: ".$file_array['size']."<br>\n";
if ( is_uploaded_file( $file_array['tmp_name'] )
&& $file_array['type'] == "text/plain" ) {
move_uploaded_file( $file_array['tmp_name'], "$file_dir/$file_name")
or die ("Couldn't copy");
print "<img src=\"$file_url/$file_name\"><p>\n\n";
}
}
?>
<body>
<form enctype="multipart/form-data" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="51200">
<input type="file" name="fupload"><br>
<input type="submit" value="Send file!">
</form>
</body>
</html>
/////