Re: Uploading Files via PHP

From: Date: Sun, 18 Feb 2001 21:24:50 +0000
Subject: Re: Uploading Files via PHP
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-40471@lists.php.net to get a copy of this message
Hmm. I don't know one thing you could try is putting $image in quotes, like '$image'. Also you might try to use the code I have pasted below. Using exec is probably not the most effecient way to do the copy of the file (and using mv limits you to *nix). Make sure you remove the checks for image type files that I make in the checkImgType() function. HTH, Michael if($Image!="none"){ $ImageExt=checkImgType($Image_type,$Image_name); } if($Image!="none"){ $ImageFinal=$ABS_PRODUCTS_IMAGES_DIR.$LastInsertID."Image".$ImageExt; copy($Image, $ImageFinal); } function checkImgType($image_type,$image_name){ if((strcmp($image_type,"image/jpeg")==0)||(strcmp($image_type,"image/gif")==0)||(strcmp($image_type,"image/pjpeg")==0)||(strcmp($image_type,"image/jpg")==0)) { switch($image_type){ case "image/jpg": $imageExt=".jpg"; break; case "image/jpeg": $imageExt=".jpg"; break; case "image/pjpeg": $imageExt=".jpg"; break; case "image/gif": $imageExt=".gif"; break; } return $imageExt; }else { print "<b><font color=red>$image_name is not a valid file to upload.<br> Please upload JPEG (.jpg) or GIF (.gif) type images only.</font></b><br>&nbsp;<br>"; return 0; } } Brian Drexler wrote:
<? exec( "mv $image '$Destination/$FileName'"); ?> ----- Original Message ----- From: Michael Stearne <mstearne@entermix.com> To: Brian Drexler <bdrexler@mail.precisionwd.com> Cc: Php-General <php-general@lists.php.net> Sent: Sunday, February 18, 2001 1:55 PM Subject: Re: [PHP] Uploading Files via PHP
The script you are using is probably checking the MIME type of the file uploaded and rejecting any of the ones that are not one of the types you listed. Look at or post some of the code you are using to find out if this is the case. Michael Brian Drexler wrote:
I've been using a PHP upload script to upload files to our server, but
my
problem is this. I can't upload anything but JPG, GIF, and HTML files. Anyone have any idea why? This is probably something simple that I'm
just
overlooking, but please help. Brian Drexler
-- 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


« previous php.general (#40471) next »