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

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.value˛ is null or not an object on this
line:
<input type="submit" name="Submit" value="Submit this Information"
accesskey="7" onclick="LimitAttach(this.form, this.form.uploadfile.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","png","jpg","jpeg"];
// the id of the preview image tag
var outImage="previewField";
// what to display when the image is not valid
var defaultPic="spacer.gif";

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

function preview(what){
var source=what.value;
var
ext=source.substring(source.lastIndexOf(".")+1,sou rce.length).toLowerCase();
for (var i=0; i<fileTypes.length; i++) if (fileTypes[i]==ext) break;
globalPic=new Image();
if (i<fileTypes.length) globalPic.src=source;
else {
globalPic.src=defaultPic;
alert("THAT IS NOT A VALID IMAGE\nPlease load an image with an extention
of one of the following:\n\n"+fileTypes.join(", "));
}
setTimeout("applyChanges()",200);
}
var globalPic;
function applyChanges(){
var field=document.getElementById(outImage);
var x=parseInt(globalPic.width);
var y=parseInt(globalPic.height);
if (x>maxWidth) {
y*=maxWidth/x;
x=maxWidth;
}
if (y>maxHeight) {
x*=maxHeight/y;
y=maxHeight;
}
field.style.display=(x<1 || y<1)?"none":""; <<<<<<<<< ERROR OBJECT REQUIRED
char 3
field.src=globalPic.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="preview(this)">
<br>
<img alt="Graphic will preview here" id="previewField" 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 13101
On 6/30/06 9:06 PM, in article C0***********************@hotmail.com,
"Jefferis NoSpamme" <je********@hotmail.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.value˛ is null or not an object on this
line:
<input type="submit" name="Submit" value="Submit this Information"
accesskey="7" onclick="LimitAttach(this.form, this.form.uploadfile.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**********************@m79g2000cwm.googlegroups. com, "Bart Van der Donck"
<ba**@nijlen.com> 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
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...
0
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? ...
7
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...
6
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...
2
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...
3
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...
5
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...
9
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...
6
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
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
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,...
1
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...
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
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.