472,353 Members | 1,222 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 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 4340
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

1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...

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.