Sorry, here's the code: <form name="form1" method="post" action="" enctype="multipart/form-data"> <input type="file" name="imagefile"> <br> <input type="submit" name="Submit" value="Submit">
<?php $filesdir = "/PIVOT"; echo $_FILES['imagefile']['name']; echo $_FILES['imagefile']['tmp_name']; if(isset( $Submit )) { if ($_FILES['imagefile']['type'] == "image/gif") { copy ($_FILES['imagefile']['tmp_name'], "$filesdir/".$_FILES['imagefile']['name']) or die ("Could not copy"); echo "<br><br>"; echo "Name: ".$_FILES['imagefile']['name']."<br>"; echo "Size: ".$_FILES['imagefile']['size']."<br>"; echo "Type: ".$_FILES['imagefile']['type']."<br>"; echo "Copy Done...."; } else { echo "<br><br>"; echo "Could Not Copy, Wrong Filetype (".$_FILES['imagefile']['name'].")<br>"; } } ?> </form> ----- Original Message ----- From: "Philip Olson" <[EMAIL PROTECTED]> To: "Rodney Green" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Sunday, June 08, 2003 1:21 AM Subject: Re: [PHP] file upload script > > By no errors, do you mean you have a PHP version greater > than PHP 4.2.0 and checked the ['error'] code, and it > has a value of 0? Are you sure you want the filename > to be $file_name? I doubt you do. > > Regards, > Philip > > ref: http://www.php.net/features.file-upload > > On Sat, 7 Jun 2003, Rodney Green wrote: > > > Hello. I'm attempting to upload a file using the script below and I'm not > > having any success. The temp directory I'm using does exist and is > > writeable. When I browse for the file then hit the send button it appears to > > be working then displays the form again with no errors. I look for the file > > on the server and it isn't there. Any advice on how to get this working? > > > > Thanks! > > Rod > > > > > > --------------------------------------------------------------- > > > > <html> > > <head> > > <title>Listing 9.14 A file upload script</title> > > </head> > > <?php > > $file_dir = "/home/corrdev/htdocs/php24/scrap/uploads"; > > $file_url = "http://corros.colo.hosteurope.com/dev/php24/scrap/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'] == "image/gif" ) { > > 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 > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php