|
Posted by Rik on 08/13/07 23:11
On Tue, 14 Aug 2007 01:05:47 +0200, macca <ptmcnally@googlemail.com> wro=
te:
> Hi people!
>
> I'm having a problem with a file upload script that I'm writing. It
> works with Firefox but not Internet explorer.
>
> When the form is submitted(to it's self) it check for a file upload
> using this:
>
>
> $room_type =3D $_POST['room_type'];
> $sleeps =3D $_POST['sleeps'];
> $description =3D $_POST['description'];
> $count =3D $_POST['count'];
> $cost_per_night =3D $_POST['cost_per_night'];
>
>
> // =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> // Configuration
> // =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> $uploaddir =3D "../account_images"; // Where the fil=
es
> to upload
> //$thumbs_dir =3D"account_images/thumbs"; // Where t=
he
> thumbnail uploads to
> // =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> // Upload Part
> // =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> if(is_uploaded_file($_FILES['file']['tmp_name']))
> {
> if(($_FILES['file']["type"] =3D=3D "image/jpeg")=
||
> ($_FILES['file']["type"] =3D=3D "image/gif") =
||
> ($_FILES['file']["type"] =3D=3D "image/png"))=
> { //200kb
> move_uploaded_file($_FILES['file']
> ['tmp_name'],$uploaddir.'/'.$_FILES['file']['name']);
> $current_file_uploaded =3D $_FILES['file']
> ['name'];
> $picture_name =3D $current_file_uploaded;
>
> }
> }
> add_room_type_to_db($room_type,$sleeps,$description,$count,
> $cost_per_night,$picture_name,$connection);
>
>
>
>
> It works fine when i test it in FF, the image is uploaded and the
> image name is inserted into the database, but when i use IE, i get an
> E_NOTICE :
>
> "Notice: Undefined variable: picture_name in C:\webserver\webroot
> \booking_system\staff\controls.php on line 208"
>
> Line 208 being the line that calls the function "add_room_type_to_db".=
>
> Any ideas why this may be happening?
The conditional is not run, either because there's no transfer, or the =
mimetype is something you don't expect. print_r($_FILES) to find out.
Also, a 'type' in an upload is something provided by the user and highly=
=
unreliable. For images, I usually use getimagesize() to check wether it'=
s =
recognized as one.
-- =
Rik Wasmus
Navigation:
[Reply to this message]
|