473,545 Members | 2,686 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Limit File Size upload?

Hello all,

I'm trying to limit the file size to 1 meg on upload of image files and I am
trying a script from javascript internet, but it is giving me errors on IE
˛ is null or not an object ł and isnąt checking the file size or preventing
the upload.
ERROR IS <<<<Śthis.form. uploadfile.valu e˛ is null or not an object on this
line:
<input type="submit" name="Submit" value="Submit this Information"
accesskey="7" onclick="LimitA ttach(this.form , this.form.uploa dfile.value)" >

http://www.sell-my-diamonds.com/submit.php

This is the script:

<!-- TWO STEPS TO INSTALL IMAGE UPLOAD PREVIEW:

1. Copy the coding into the HEAD of your HTML document
2. Add the last code into the BODY of your HTML document -->

<!-- STEP ONE: Paste this code into the HEAD of your HTML document -->

<HEAD>

<script type="text/javascript">
<!-- Begin
/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Abraham Joffe :: http://www.abrahamjoffe.com.au/ */

/***** CUSTOMIZE THESE VARIABLES *****/

// width to resize large images to
var maxWidth=500;
// height to resize large images to
var maxHeight=500;
// valid file types
var fileTypes=["bmp","gif","pn g","jpg","jp eg"];
// the id of the preview image tag
var outImage="previ ewField";
// what to display when the image is not valid
var defaultPic="spa cer.gif";

/***** DO NOT EDIT BELOW *****/

function preview(what){
var source=what.val ue;
var
ext=source.subs tring(source.la stIndexOf(".")+ 1,source.length ).toLowerCase() ;
for (var i=0; i<fileTypes.len gth; i++) if (fileTypes[i]==ext) break;
globalPic=new Image();
if (i<fileTypes.le ngth) globalPic.src=s ource;
else {
globalPic.src=d efaultPic;
alert("THAT IS NOT A VALID IMAGE\nPlease load an image with an extention
of one of the following:\n\n" +fileTypes.join (", "));
}
setTimeout("app lyChanges()",20 0);
}
var globalPic;
function applyChanges(){
var field=document. getElementById( outImage);
var x=parseInt(glob alPic.width);
var y=parseInt(glob alPic.height);
if (x>maxWidth) {
y*=maxWidth/x;
x=maxWidth;
}
if (y>maxHeight) {
x*=maxHeight/y;
y=maxHeight;
}
field.style.dis play=(x<1 || y<1)?"none":"" ; <<<<<<<<< ERROR OBJECT REQUIRED
char 3
field.src=globa lPic.src;
field.width=x;
field.height=y;
}
// End -->
</script>
</HEAD>

<!-- STEP TWO: Copy this code into the BODY of your HTML document -->

<BODY>

<div align="center" style="line-height: 1.9em;">
Test it by locating a valid file on your hard drive:
<br>
<input type="file" id="picField" onchange="previ ew(this)">
<br>
<img alt="Graphic will preview here" id="previewFiel d" src="spacer.gif ">
<br> <div style="font-size: 7pt;">

~~~~~~~~~~~~
Jefferis Peterson, Pres.
Web Design and Marketing
http://www.PetersonSales.com

Jul 1 '06 #1
3 13119
On 6/30/06 9:06 PM, in article C0************* **********@hotm ail.com,
"Jefferis NoSpamme" <je********@hot mail.com> wrote:
Hello all,

I'm trying to limit the file size to 1 meg on upload of image files and I am
trying a script from javascript internet, but it is giving me errors on IE ˛
is null or not an object ł and isnąt checking the file size or preventing the
upload.
ERROR IS <<<<Śthis.form. uploadfile.valu e˛ is null or not an object on this
line:
<input type="submit" name="Submit" value="Submit this Information"
accesskey="7" onclick="LimitA ttach(this.form , this.form.uploa dfile.value)" >

http://www.sell-my-diamonds.com/submit.php


I found that the error on the form was due to using a function from another
script which didnąt belong on this form.

However, There is no file checking for size in the script. Does this have to
be done server side?

Jeff
~~~~~~~~~~~~
Jefferis Peterson, Pres.
Web Design and Marketing
http://www.PetersonSales.com

Jul 1 '06 #2
Jefferis NoSpamme wrote:
[...]
I found that the error on the form was due to using a function from another
script which didnąt belong on this form.

However, There is no file checking for size in the script. Does this haveto
be done server side?


Yes - there's no other way than doing the whole upload, and then let
the programme that parses the input perform the check on file size.

--
Bart

Jul 1 '06 #3
On 7/1/06 4:49 AM, in article
11************* *********@m79g2 00...legr oups.com, "Bart Van der Donck"
<ba**@nijlen.co m> wrote:
Yes - there's no other way than doing the whole upload, and then let
the programme that parses the input perform the check on file size.

--
Bart


Thanks
Jeff
~~~~~~~~~~~~
Jefferis Peterson, Pres.
Web Design and Marketing
http://www.PetersonSales.com

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Jul 1 '06 #4

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

Similar topics

8
1999
by: Randell D. | last post by:
Folks, Sorry for the cross post into multiple newsgroups on this, but html forms processing is supported across all three groups so I was hoping someone might know. I did a check with Google and found dated 1996 and 1997... This is a bit too old for me to rely on... Thus... Does anyone know if there is a limit when POSTing? I think a
0
1405
by: Antonio.P | last post by:
Hi to all. I am using an html form to upload files to zope. I'd like to limit the max upload size to 3Mb but I haven't found anything on the manual about it. Is it possible to put this limit? Thank you.
7
5666
by: Joey C. | last post by:
Hello, I'm designing a small "briefcase" program that will allow me to quickly upload, download, and delete files in a briefcase. The only real things that I have left to do are to design a method for checking if the file exists, preventing it from overwriting files from other directories, and setting a user-configurable maximum limit on the...
6
2082
by: Tom Kaminski [MVP] | last post by:
Is there anyway to gracefully catch a file upload limit error? When the limit is exceeded, IE displays a generic "Cannot find server or DNS error" message. -- Tom Kaminski IIS MVP http://www.microsoft.com/windowsserver2003/community/centers/iis/ http://mvp.support.microsoft.com/ http://www.iisfaq.com/ http://www.iistoolshed.com/ -...
2
552
by: lawrence k | last post by:
I've a file upload script on my site. I just now used it to upload a small text document (10k). Everything worked fine. Then I tried to upload a 5.3 meg Quicktime video. Didn't work. I've set the POST limit in php.ini to 8 megs. What reasons, other than the POST limit, would a large upload fail?
3
1599
by: darrel | last post by:
I've built a file upload component for our CMS so people can upload images, PDFs, etc. I just ran into a snag with an 8mb PDF file. If I try to upload this, I immediate get a 'application has timed out error, try again?'. Any other file goes fine, but not this huge PDF file. Is there a default file size limit uploading files via HTTP...
5
3720
by: Jefferis NoSpamme | last post by:
Hi all, I'm trying to limit the file size of an image submission and I keep running into various problems. I've got most of it working, but I'm stumped and I have a basic question as to WHY this works at all! if ($_FILES !="") { if ($_FILES<=0) { header("Location: /fileerror.php"); exit; }
9
2830
by: freduchi | last post by:
Hi, I need sugestions. I need to implement the next and I don´t know how to do it: I am developing a website in which users are signed up and share information(Messages, Photos...). When a user is signed up, his data is stored in a database and he is asigned with a folder. What I need, is to limit the folder capacity of each user to a...
6
4852
by: howa | last post by:
Suppose the file is stored in "upload_tmp_dir ", so why I need to increase the memory limit? If I want to upload 100 MB, how large should I set? Thanks.
0
7496
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7685
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7941
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7452
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6014
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5354
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3467
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1916
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
738
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.