Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Mix Binary and Text Content Problem
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Applications Internet
Titre:
Mix Binary and Text Content Problem
Divers
Thread ID:
00669871
Message ID:
00669871
Vues:
61
Having a problem with mixing binary-text data for an HTTP POST. If I use boot.ini as my file-to-send, it gets to the web server fine. If I use chimes.wav, it doesn't get there. :(

Can anyone tell me how I should transform the bytes so they will send correctly? They always seem to get truncated after a few bytes. It doesn't seem to matter if I use cContent = FileToStr or cContent = CreateBinary(FileToStr ....
	vbCRLF = Chr(13)+Chr(10)
	Clear
*	cFile = 'c:\winnt\media\chimes.wav'
	cFile = "c:\boot.ini"
	cContent =  FileToStr(cFile) 
	? Transform(Len(cContent)) 
	cAddr = 'http://127.0.0.1:8080/wteupload.asp'
	oHTTP = CreateObject('Msxml2.ServerXMLHTTP.4.0')
	oHTTP.Open( 'POST' , cAddr , .f. , 'testdom1\testdomuser1' , 'password' )
	cBoundary = '---AaB03x'
	oHTTP.SetRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' )
	oHTTP.SetRequestHeader( 'Content-Type', 'multipart/form-data, boundary=' + cBoundary )
	oHTTP.SetRequestHeader( 'Content-Length', Transform(Len(cContent))  )
	cBody = '--' + cBoundary + vbCRLF + ; 
		'Content-Disposition: form-data; name="thefile1"; filename='+(cFile)+'"'+ vbCRLF + ; 
		'Content-Type: image/gif' + vbCrLf + vbCRLF + ; 
		cContent + vbCRLF +'--' + ; 
		cBoundary + vbCRLF + ; 
		'Content-Disposition: form-data; name="submit1"' + vbCRLF + vbCRLF + ; 
		'Submit' + vbCRLF + vbCRLF + '--' + cBoundary + '--'
	oHTTP.Send(cBody)
	? oHTTP.ResponseText
I created a simple .ASP page using Soft Artistan's SA-FileUp to catch the upload. This works fine if I use either IE to do the upload or use the above code on a text file.

Thanks, I am desperate!
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform