sign in | join about | help | sitemap
Connecting Tech Pros Worldwide
Paul Hamlington's Avatar

Image upload problem with jpegs


Question posted by: Paul Hamlington (Guest) on July 19th, 2005 06:32 AM
Hello,

I've been programming in ASP for a little while now and quite an
advanced user, but I have come across an unusual problem in which I
need assistance.

I have built my own image upload, I have two versions of the binary to
string conversion one fast, one slow because some servers use
chillisoft and therefore the append function in not accessible for a
disconnected recordset.

Slow conversion:

function b2s(varBinData, intDataSizeInBytes)
for nindex = 1 to intDataSizeInBytes
asc_data1 = asc_data1 & chr(ascb(midb(varBinData,nindex,1)))
next
b2s = asc_data1
end function

Fast conversion:

function b2s(varBinData, intDataSizeInBytes)
const adFldLong = &H00000080
const adVarChar = 200
const adUseClient = 3
set cvs = server.createobject("adodb.recordset")
cvs.CursorLocation = adUseClient
cvs.fields.append "txt", adVarChar, intDataSizeInBytes, adFldLong
cvs.open
cvs.addnew
cvs.fields("txt").appendchunk varBinData
b2s = cvs("txt").value
cvs.close
set cvs = nothing
end function

obviously I pass the data size and data through to the function.

The problem I have is this, my image upload works find on my local
machine which is windows XP, I can upload anything using the browser,
and the file upload is fine, but as soon as I do this on a Linux box
with chillisoft I get problems. A gif image will upload correctly no
problems, but a jpeg for some reason the first 8 characters of the
file are changed and therefore the image doesn't work. Now I've done a
binarywrite through out the upload process to see if its converting
binary data correctly and it is, it just seems to corrupt first 8
characters of image when saving the file.

Save Function Used:

'*** Save Uploaded Files ***'
sub save_file(i_data,filepath,f_value)
'*** Setting path and filename ***'
filepath = filepath & f_value
savepath = server.mappath(filepath)

'*** Save File ***'
set fs = server.createobject("scripting.filesystemobject")
set savefile = fs.createtextfile(savepath, overwrite, False)
savefile.write i_data
savefile.close
set savefile = nothing
set fs = nothing
end sub

Has anyone seen this before and is able to assist me in fixing this
problem.
0 Answers Posted
 
Not the answer you were looking for? Post your question . . .
196,989 members ready to help you find a solution.
Join Bytes.com

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 196,989 network members.
Post your question now . . .
It's fast and it's free

Popular Articles

Top Community Contributors