Re: FILE UPLOAD Q
| From: | Philip Olson | Date: | Sun, 08 Jun 2003 07:22:07 +0000 |
| Subject: | Re: FILE UPLOAD Q | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-150648@lists.php.net to get a copy of this message | ||
That article is pretty old, and the code sucks.
Read this instead:
http://www.php.net/features.file-upload
It will explain everything.
Regards,
Philip
On Sun, 8 Jun 2003, nabil wrote:
> 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>
>
>
> /////
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>