Image upload problem with jpegs

  • Thread starter Paul Hamlington
  • Start date


Paul Hamlington


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)))
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.fields("txt").appendchunk varBinData
b2s = cvs("txt").value
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
set savefile = nothing
set fs = nothing
end sub

Has anyone seen this before and is able to assist me in fixing this


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question