Moving images in PHP

Get help on web editors (Frontpage, Dreamweaver) and web languages (HTML, ASP, PHP).
Post Reply
Shelv
Registered User
Posts: 3
Joined: 27 Mar 2011, 10:12

Moving images in PHP

Post by Shelv »

Hey guys & girls

I'm trying to move images in php but it's not working.

Code: Select all

<?php
                                            if (isset($_POST['submit'])) {
                                                if ((($image_type == 'image/jpg') || ($image_type == 'image/pjpeg') || ($image_type == 'image/bmp') || ($image_type == 'image/gif'))
                                                      && ($image_size > 0) && ($image_size <= MYWORLD_MAXFILESIZE)) {
                                                    // Move file to upload target folder
                                                    $target = MYWORLD_UPLOADPATH . $image;
                                                    if (move_uploaded_file($_FILES['screenshot']['tmp_name'], $target)) {
                                                        echo 'Image uploaded successfully';
                                                    } else {
                                                        $errors[] = 'Failed to move the uploaded file';
                                                        echo 'Failed to move the uploaded file';
                                                    }
                                                } else {
                                                    $errors[] = 'Only jpeg, bmp or gif files allowed to a maximum size of 1mb';
                                                    echo 'Only jpeg, bmp or gif files allowed to a maximum size of 1mb';
                                                }
                                            }
                                            ?>
I always get the last echo no matter what file type or size of the file.

Any help would be much appreciated :)
RuadRauFlessa
Registered User
Posts: 20576
Joined: 19 Sep 2003, 02:00
Location: Bloodbank

Re: Moving images in PHP

Post by RuadRauFlessa »

do an echo of $image_type at the top before

Code: Select all

if ((($image_type == 'image/jpg') || ($image_type == 'image/pjpeg') || ($image_type == 'image/bmp') || ($image_type == 'image/gif'))
and check what it is. Looks like you might want to change the values you are looking for.
:rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock:
Spoiler (show)
Intel Core i7-2600k @ 3.4GHz
Corsair Vengence 2x4GB DDR3 2000MHz
Thermaltake Toughpower 850W
ASUS nVidia GTX560 1GB
CoolerMaster HAF 932
Post Reply