Forums

ASP

This topic is locked

on upload, gif changes to jpg

Posted 16 Nov 2006 18:46:34
1
has voted
16 Nov 2006 18:46:34 sag gie posted:
Hello, rather a newbie here. I have an upload pack on my website (appears to be ASP File Upload version 2.17which came with some files such as incPureUpload.asp and incPureUpload.js and has some addon files such as PUAddOn.asp, ResizeAddOn.asp, and ResizeImage.aspx. Not sure what's up, but when I use the program to upload images, all gif files are automatically changed to jpg files....argh!

I found a piece in the code of the incPureUpload.js file that shows something I would guess to be suspiscious of, but way not sure what to do with this if it is the right piece.

At any rate, I am trying to get the prog to not change file names. Wonder why that would be needed.

The code suspiscious of:
=====================
function checkOneFileUpload(field, extensions, requireUpload, sizeLimit, minWidth, minHeight, maxWidth, maxHeight, saveWidth, saveHeight) {
var fileName = field.value.replace(/"/gi,'');
field.uploadOK = false;
if (fileName == '') {
if (requireUpload) {
alert('File is required!');
field.focus();
return;
} else {
field.uploadOK = true;
}
} else {
if (extensions != '') {
checkFileExtension(field, fileName, extensions);
} else {
field.uploadOK = true;
}
if (!document.layers && field.uploadOK) {
document.PU_uploadForm = field.form;
re = new RegExp("\.(gif|jpg|png|bmp|jpeg)$","i";
if(re.test(fileName) && (sizeLimit != '' || minWidth != '' || minHeight != '' || maxWidth != '' || maxHeight != '' || saveWidth != '' || saveHeight != '')) {
checkImageDimensions(field,sizeLimit,minWidth,minHeight,maxWidth,maxHeight,saveWidth,saveHeight);
}
}
}
return;
}

function checkFileExtension(field, fileName, extensions) {
var re = new RegExp("\\.(" + extensions.replace(/,/gi,"|".replace(/\s/gi,"" + "$","i";
var agt = navigator.userAgent.toLowerCase();
var is_mac = (agt.indexOf("mac" != -1);
var is_op = (agt.indexOf("opera" != -1);
if (is_op) {
var ext = fileName.substring(fileName.lastIndexOf('.')+1, fileName.length);
var extArr = extensions.split(',');
var extCheck = false;
for (var i = 0; i < extArr.length; i++) {
if (extArr[i].toLowerCase() == ext.toLowerCase()) {
extCheck = true;
break;
}
}
if (extCheck == false) {
alert('This file type is not allowed for uploading.\nOnly the following file extensions are allowed: ' + extensions + '.\nPlease select another file and try again.');
field.focus();
field.uploadOK = false;
return;
}
} else {
if (!re.test(fileName)) {
alert('This file type is not allowed for uploading.\nOnly the following file extensions are allowed: ' + extensions + '.\nPlease select another file and try again.');
field.focus();
field.uploadOK = false;
return;
}
}
field.uploadOK = true;
}
==============

Thanks a ton...

saggie

Reply to this topic