473,395 Members | 1,972 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,395 software developers and data experts.

Javascript Finding an Image's property.

3
Hi All,
Im new to the web development.... Here I wanna know some codes which support the following criteria..
1) Restricting other files except image files.
2) Restricting image file with the specified length(length in bytes)
3) Restricting image file with the specified Size(Dimensions)

I could able to manage the above criterias through javascript...But the problem is im not able to generalize the code with all the browsers (i.e., Working in IE, but not in Firefox). :confused:

Could any one tell me the solution
Jul 31 '06 #1
5 4379
iam_clint
1,208 Expert 1GB
Yes i could tell you the solution more then likely if you post your question in a better way i am not fully understanding what you are wanting it to do. restrict everything but images, the image size and the image dimensions.

what do you mean by restrict?
Aug 1 '06 #2
jarjis
3
Hi,
Thanks for the reply...

We have to restrict the user to upload/select/browse other files(such as txt, doc) through browse field...Moreover I have to restrict the user to donot upload the image which is different in size(dimension) and in length(bytes). Looking for the reply...Thank you.... :)
Aug 1 '06 #3
iam_clint
1,208 Expert 1GB
What code are you using for the upload.. you can do everything your talking about in PHP and ASP, javascript wouldn't be practical for this application because javascript is client side and anyone determined will beable to upload any file they want... so server side would be the best way to go other then that for javascript look into javscript image.fileSize for bytes and image.width and image.height...
Aug 1 '06 #4
jarjis
3
Hi
Here i wanted to do that through client side script. Is this possible to acheive it?

function getFileSize (fileName) {
if (document.layers) {
if (navigator.javaEnabled()) {
var file = new java.io.File(fileName);
if (location.protocol.toLowerCase() != 'file:')
netscape.security.PrivilegeManager.enablePrivilege ('UniversalFileRead');
return file.length();
}
else return -1;
}
else if (document.all) {
window.oldOnError = window.onerror;
window.onerror = function (err) {
if (err.indexOf('utomation') != -1) {
alert('file access not possible');
return true;
}
else
return false;
};
var fso = new ActiveXObject('Scripting.FileSystemObject');
var file = fso.GetFile(fileName);
window.onerror = window.oldOnError;
return file.Size;
}
}

in this code im not able to get the file size in FIREFOX

Thank you.
Aug 2 '06 #5
acoder
16,027 Expert Mod 8TB
Hi
Here i wanted to do that through client side script. Is this possible to acheive it?

[snip]

in this code im not able to get the file size in FIREFOX

Thank you.
Firefox (correctly) does not allow access to local files. However, I would have hoped that harmless files such as image files would be allowed...
Nov 24 '06 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.