Forums

ASP

This topic is locked

Limit Picture Size with ASP Upload

Posted 11 Nov 2003 23:39:55
1
has voted
11 Nov 2003 23:39:55 phil piggott posted:
I need to upload a thumbnail and also a large picture to every record in my database using a single form. Using ASP Upload I can set the file dimension max and min, but it applies the same size to BOTH file upload fields on my form.

I need to set limits for the thumbnail and large picture individually. Any suggestions?

Replies

Replied 12 Nov 2003 10:44:40
12 Nov 2003 10:44:40 Patrick Woldberg replied:
It is done by javascript, it updates the hidden fields. In your code you find something like checkFileUpload(this,'GIF,JPG,JPEG,BMP,PNG',true,'','','','','','hiddenfield1','hiddenfield2') on the form tag and checkOneFileUpload(this,'GIF,JPG,JPEG,BMP,PNG',true,'','','','','','hiddenField1','hiddenField2') on the filefields.

The last 2 parameters are the hidden fields, to get the sizes of all filefields you need to make for each filefield 2 hiddenfields. In the form tag function remove the field names, make it empty strings like ''. Then for each filefield point to the correcponding hiddenfields. Underneed a sample for the form.

<pre id=code><font face=courier size=2 id=code>&lt;form action="&lt;%=GP_uploadAction%&gt;" method="post" enctype="multipart/form-data" name="form1" onSubmit="checkFileUpload(this,'GIF,JPG,JPEG,BMP,PNG',true,'','','','','','','');return document.MM_returnValue"&gt;
&lt;input name="file" type="file" onChange="checkOneFileUpload(this,'GIF,JPG,JPEG,BMP,PNG',true,'','','','','','width','height')"&gt;
&lt;input type="hidden" name="width"&gt;
&lt;input type="hidden" name="height"&gt;&lt;br&gt;
&lt;input name="file2" type="file" onChange="checkOneFileUpload(this,'GIF,JPG,JPEG,BMP,PNG',true,'','','','','','width2','height2')"&gt;
&lt;input type="hidden" name="width2"&gt;
&lt;input type="hidden" name="height2"&gt;&lt;br&gt;
&lt;input type="submit" name="Submit" value="Upload"&gt;
&lt;/form&gt;</font id=code></pre id=code>

--------------------------------------------------
Patrick Woldberg
Web Developer at Dynamic Zones
Manager at DMXzone.com
--------------------------------------------------
Replied 13 Nov 2003 19:32:12
13 Nov 2003 19:32:12 phil piggott replied:
Many thanx, but this saves the image width and height into the hidden fields.

I need to set the min and max width and height individually for two different filefields - ie I need the image in filefield1 to be 50-100 pixels wide and 50-100 pixels high, and the image in filefield2 to be 400-800 pixels wide and 400-800 pixels high. Both filefields are on the same form.

Hope this makes sense
Replied 17 Nov 2003 17:32:37
17 Nov 2003 17:32:37 Patrick Woldberg replied:
<pre id=code><font face=courier size=2 id=code>
&lt;form action="&lt;%=GP_uploadAction%&gt;" method="post" enctype="multipart/form-data" name="form1" onSubmit="checkFileUpload(this,'GIF,JPG,JPEG,BMP,PNG',true,'','','','','','','');return document.MM_returnValue"&gt;
&lt;input name="file" type="file" onChange="checkOneFileUpload(this,'GIF,JPG,JPEG,BMP,PNG',true,'',50,100,50,100,'width','height')"&gt;&lt;br&gt;
&lt;input name="file2" type="file" onChange="checkOneFileUpload(this,'GIF,JPG,JPEG,BMP,PNG',true,'',400,800,400,800,'width2','height2')"&gt;
&lt;input type="submit" name="Submit" value="Upload"&gt;
&lt;/form&gt;
</font id=code></pre id=code>

--------------------------------------------------
Patrick Woldberg
Web Developer at Dynamic Zones
Manager at DMXzone.com
--------------------------------------------------
Replied 21 Nov 2003 19:46:55
21 Nov 2003 19:46:55 phil piggott replied:
Thanks for the info, I'll try it out over the weekend!

Reply to this topic