Re: [PHP] File Type not working in Uploaded File
Hi, Ok there were a lot of mistakes in that code. IN fact i rubbed it off completely and am using a new code.. Everything works fine now, except that if the filename exists, any new file with the same name overwrites the old file.. What do i do about it? Here is the code i'm using : ?php $db = mysql_connect(localhost,user,pwd); mysql_select_db(dbname,$db); if ($img1_name != ) { $pic = yes; } else { $pic = no; } $date = date(l dS of F Y h:i:s A); // if $img_name isn't empty, try to copy the file if (($img1_name != ) and ($img1_size = 256000) and ($img1_type == image/pjpeg) or ($img1_type == image/jpeg)) { $sql = INSERT INTO mjpals (name,age,gender,country,email,date,profile,looking,pic_name,pic) VALUES ('$name','$age','$gender','$country','$email','$date','$profile','$looking','$img1_name','$pic'); $result = mysql_query($sql) or die(You made a mistake, please go back and try again); copy($img1, mjpalpics/$img1_name) or Die (Could not do); } ? Thank you for adding you details. The following has been added to the Database :brbr big ?php $profile = stripslashes($profile); $looking = stripslashes($looking); echo ( Name : $namebr Age : $agebr Gender : $genderbr Country : $countrybr Email : $emailbr Your Profile : $profilebr You are looking for : $lookingbr ); if (($img1_size = 256000) and ($img1_type == image/pjpeg) or ($img1_type == image/jpeg)) { echo Your Photo : iName - $img1_name | Size - $img1_size | MIME Type - $img1_type/i br ; } else { echo No photograph uploaded, or wrong Type/Size photograph; } ? = Rahul S. Johari (Director) ** Abraxas Technologies Inc. Homepage : http://www.abraxastech.com Email : [EMAIL PROTECTED] Tel : 91-4546512/4522124 *** __ Do You Yahoo!? LAUNCH - Your Yahoo! Music Experience http://launch.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] File Type not working in Uploaded File
Hi, This is my upload form : form action=upload.php method=POST enctype=multipart/form-data p align=centerfont size=2 face=VerdanastrongPlease upload your file below:/p input type=file name=file size=30 pinput type=button name=submit type=submit Upload /form And this is part of my PHP coding, that handles the Upload. Basically the problem is, that my code is not recognising the File Type! I have specified image/jpeg as the file type, but even then it does not upload ANY file at all. In fact it gives the specific error which i have associated when the file type is wrong. * $allow_type = image/jpeg; $allow_file_type = 1; $not_correct_file = bfont face=\$font\ size=\$font_size\ color=\$font_color\Sorry, but the file you tried to upload is not valid file to upload!; if ($allow_file_type == 1) { if ($allow_type != $type) { die($not_correct_file); } } * Why is it that it is NOT recognising ANY file type. I tried removing the Cheking of FILE type, and the program was working fine, where it was Uploading ANY file. However, as soon as i put in this particular code to check for File Type, it does NOT upload any file. Help! T. Edison Jr. = Rahul S. Johari (Director) ** Abraxas Technologies Inc. Homepage : http://www.abraxastech.com Email : [EMAIL PROTECTED] Tel : 91-4546512/4522124 *** __ Do You Yahoo!? Yahoo! Shopping - Mother's Day is May 12th! http://shopping.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File Type not working in Uploaded File
Well, first thing I notice is that in your form you name your file input as file, yet nowhere in your code do I see you getting any values from _FILES or $file (depending on your version of PHP). So...how do you expect it to do anything with your file if you don't tell it to?? Maybe you left out the part of your code that does that... Also, you set allow_file_type to 1, then you say if($allow_file_type == 1)...well, duh, of course it's equal to one, you just set it to one...what are you trying to accomplish with that? Also, where is $type coming from? ---John Holmes... - Original Message - From: Thomas Edison Jr. [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, May 10, 2002 12:18 PM Subject: [PHP] File Type not working in Uploaded File Hi, This is my upload form : form action=upload.php method=POST enctype=multipart/form-data p align=centerfont size=2 face=VerdanastrongPlease upload your file below:/p input type=file name=file size=30 pinput type=button name=submit type=submit Upload /form And this is part of my PHP coding, that handles the Upload. Basically the problem is, that my code is not recognising the File Type! I have specified image/jpeg as the file type, but even then it does not upload ANY file at all. In fact it gives the specific error which i have associated when the file type is wrong. * $allow_type = image/jpeg; $allow_file_type = 1; $not_correct_file = bfont face=\$font\ size=\$font_size\ color=\$font_color\Sorry, but the file you tried to upload is not valid file to upload!; if ($allow_file_type == 1) { if ($allow_type != $type) { die($not_correct_file); } } * Why is it that it is NOT recognising ANY file type. I tried removing the Cheking of FILE type, and the program was working fine, where it was Uploading ANY file. However, as soon as i put in this particular code to check for File Type, it does NOT upload any file. Help! T. Edison Jr. = Rahul S. Johari (Director) ** Abraxas Technologies Inc. Homepage : http://www.abraxastech.com Email : [EMAIL PROTECTED] Tel : 91-4546512/4522124 *** __ Do You Yahoo!? Yahoo! Shopping - Mother's Day is May 12th! http://shopping.yahoo.com -- 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