Jump to content

All files seen as JPEG on upload


intech

Recommended Posts

Strange...I have done many simple file upload scripts and this one is baffeling me:

First off, Here is my code (minus the MySQl connection-MySQL is working fine w/no issues):

[code]if((is_uploaded_file($_FILES['homeri1']['tmp_name'])) && ($_FILES['homeri1']['type'] == 'image/jpeg' || 'image/pjpeg')) {
$filename1 = addslashes($_FILES['homeri1']['name']);
$filetmp1 = $_FILES['homeri1']['tmp_name'];
$filetype1 = $_FILES['homeri1']['type'];
$filesize1 = $_FILES['homeri1']['size'];
$filedest1 = 'oosup/';
    }
    else {
$filename1 = '';
    }

// Standard MySQL connection

    mysql_select_db("oosdb1")
or die("<b>Database Error. Please contact Integrated Technologies.</b>");

    $query_update1 = "UPDATE home SET
    home_lp1='$homelp1',home_lp2='$homelp2',home_lp3='$homelp3',home_lp4='$homelp4',
    home_lp5='$homelp5',home_lp6='$homelp6',home_lp7='$homelp7',home_ri1='$filename1'
      WHERE table_name='home' limit 1";

    $result_update1 = mysql_query($query_update1)
or die(mysql_error());

    if(($filename1 != '') && (!file_exists($filedest1 . stripslashes($filename1)))) {
move_uploaded_file($filetmp1, $filedest1 . stripslashes($filename1));
    }[/code]

What it should do:
1) Verify the file was indeed a file upload AND verify the file is of file type JPEG
2) IF both these conditions are met, then initialize the simple variables OR ELSE set the main variable of $filename1 to blank.
3) Insert the file name into my MySQL table (works fine)
4) IF $filename1 DOES NOT equal blank and does not exist, move the file to the destination folder.

What it is currently doing:
1) When I try to upload a .txt, .pdf or any other file type, it STILL uploads the file AND inserts the file name into the MySQL table.

I have verified this in both IE 6, Firefox AND Opera.

I am at a loss. I have had a very long night of trying to find the error in my code that is allowing ALL file types to be uploaded. (I DO NOT receive any PHP errors or warnings).

PHP Version: 4.4.4
OS Version: Windows XP PRO/IIS 5.1

My gratitude ahead of time...
Link to comment
https://forums.phpfreaks.com/topic/35707-all-files-seen-as-jpeg-on-upload/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.