473,387 Members | 1,536 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Inconsistent type checking results

(Also posted in dreamweaver forum)

I have two *.jpg files. They both display perfectly on my local system. I
have a check on the type of file in my upload where I check the first five
characters for "image".

One uploads and the other does not.
One passes the "image" test and the other has an empty string there, so it
fails the upload.

If I copy that one that fails to a location on the server using Dreamweaver
(outside of my php script) and then try to display it in my web page, it
displays perfectly.

Does anyone have a clue?

Shelly
Jul 24 '05 #1
4 1309
There are two main types of jpg in the system - jpeg and pjpeg. One
solution is to use the PHP command getimagesize - see
http://uk2.php.net/manual/en/function.getimagesize.php . The array it
returns contains the type of image the supplied file is.

Jul 24 '05 #2

<pf******@hotmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
There are two main types of jpg in the system - jpeg and pjpeg. One
solution is to use the PHP command getimagesize - see
http://uk2.php.net/manual/en/function.getimagesize.php . The array it
returns contains the type of image the supplied file is.


I'll try that (in a few weeks), but I am not sure I made myself clear to you
as to what my problem is. Let me clarify.

I use type=file in the html description of the field with a name of
name=filename. Then when I check the type from that one of the images is
"image" for the first five characters of the type, but the other is blank.
They are both jpg extensions. What I use is $_FILES['filename']['type'],
the global variable filled in by the file type textbox using the browse
button supplied.

Now from reading the documentation it seems to me that getimagesize() is a
server-side function to get the details on a file that is on the server. I
do the testing before actually uploading the file. This is standard
procedure. If the file is not of the proper type, the upload is not done.
Dos the getimagesize() work on a file on the user's system? I would think
not because that would allow the server to browse the user's system
indiscriminately, rather than merely looking at the supplied file -- a major
privacy breach.

Shelly
Jul 24 '05 #3
Shelly wrote:
I have two *.jpg files. They both display perfectly on my local system. I
have a check on the type of file in my upload where I check the first five
characters for "image".
Is that check $_FILES['filename']['type']? As another poster
suggested, you could use getimagesize() to determine the type;
or mime_content_type(); or a mixture of all three.
$_FILES['filename']['type'], if given at all, is from the
browser, and so you can't rely on it being 100 % accurate.
One uploads and the other does not.
actually doesn't upload? If so, what error is reported?
One passes the "image" test and the other has an empty string there, so it
fails the upload.
...or it uploads but you discard it because of your "image"
test?
If I copy that one that fails to a location on the server using Dreamweaver
(outside of my php script) and then try to display it in my web page, it
displays perfectly.


Where are the jpegs, and I can try at my end. (I trust they
aren't dirty!?)

--
Jock
Jul 24 '05 #4

"John Dunlop" <us*********@john.dunlop.name> wrote in message
news:MP************************@news.ntlworld.com. ..
Shelly wrote:
I have two *.jpg files. They both display perfectly on my local system.
I
have a check on the type of file in my upload where I check the first
five
characters for "image".


Is that check $_FILES['filename']['type']? As another poster
suggested, you could use getimagesize() to determine the type;
or mime_content_type(); or a mixture of all three.
$_FILES['filename']['type'], if given at all, is from the
browser, and so you can't rely on it being 100 % accurate.


Interesting.
One uploads and the other does not.


actually doesn't upload? If so, what error is reported?


None. I do checking and report my own message.
One passes the "image" test and the other has an empty string there, so
it
fails the upload.


...or it uploads but you discard it because of your "image"
test?


I don't know for sure. I assumed it didn't upload but maybe it did and I
threw it away. I thought the check was before it actually uploaded.
If I copy that one that fails to a location on the server using
Dreamweaver
(outside of my php script) and then try to display it in my web page, it
displays perfectly.


Where are the jpegs, and I can try at my end. (I trust they
aren't dirty!?)


Of course not. However, I am away on vacation and so I can't send them now
as they are on my home computer. Thanks anyway.

Shelly
Jul 24 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Web Developer | last post by:
Hi, I come across the term "type checking" very often in my readings on C++, and have never heard it in Java. Besides the simplistic answer that it checks the "type", what more does it mean? ...
1
by: Ellen Manning | last post by:
I've got an A2K continuous form based on a query of 2 tables. The query returns results if the field "Outstanding" = Yes. The form's recordset type is set to Inconsistent Updates. If the user...
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
20
by: Francine.Neary | last post by:
I am learning C, having fun with strings & pointers at the moment! The following program is my solution to an exercise to take an input, strip the first word, and output the rest. It works fine...
1
by: catudalg | last post by:
Configuration: Windows 2000 sp3 MS Access 2000 (9.0.4402 SR-1) Visual Foxpro 9.0 detached tables MS VFP Driver 6.01.6830.01 06/19/2003 For example, a simple query like: select * from ddwg1...
17
by: Dudely | last post by:
My web page displays just fine under IE7, but under IE6 about 90% of it is just plain missing. I get the top of the page, and the bottom of the page... but not the middle. I have not tested with...
6
by: Mad Hatter | last post by:
Hi folks I'm a bit confused with an upload script that I've written. I want to be able to check the file type of an upload by checking the mime type but I'm not getting the results that I...
3
by: Rahul Babbar | last post by:
Hi All, When could be the possible reasons that could make a database inconsistent? I was told by somebody that it could become inconsistent if you " force all the applications to a close on...
1
by: rnhuch | last post by:
My platform is SQL Server 2005. One of the tables of my db has 28589928 rows and one of the fields is real. When I backup and restore this database to another server (using the SQL Server internal...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.