Re: uploading files

From: Date: Tue, 27 Jun 2000 05:30:06 +0000
Subject: Re: uploading files
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-3282@lists.php.net to get a copy of this message
Here you go. This is a basic PHP script to handle file uploads: <? if (isset($file) && $file != "none") { /* the syntax of this is copy("path to original file", "path and name of destination"); $file stores the name and path of the temporary file. Note: if you don't copy the file immediately after upload, it will get deleted. The upload temp directory is set in php.ini and defaults to /tmp on *nix */ if (!copy($file,"/tmp/$file_name") echo "Error copying file: $file_name<br>"; $file = "none"; } ?> The html portion of the code would go something like this: <form method="POST" action="<? echo $PHP_SELF; ?>" enctype="multipart/form-data"> <INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="2000000"> <input type=file name=file> <input type=submit value="Upload Image"> </form> Jason ----- Original Message ----- From: "ScourNepal.com" <sales@scournepal.com> To: <php-general@lists.php.net> Sent: Tuesday, June 27, 2000 12:05 AM Subject: [PHP-GENERAL] uploading files > I went through the manual, but it hardly helped me. I want to have a > form to upload a file (a pic) and rename it once its uploaded... > > I couldn't understand the copy() syntax... Can anyone please send me a > link (a tutorial, etc...) or some information please? > > And I also wanted to know: How can I have a "Browse" button on my page > so that I can choose the file to upload from my hard disk? > > thanks. > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > _______________________________________________________ Site Design, Hosting, and E-Commerce at www.webpipe.net

« previous php.general (#3282) next »