非常感谢版主,0点了还在帮我解决问题。其实一开始确实是我理解的问题,把版主带偏了。非要通过读写文本来操作,以至于走了弯路。之所以一直没有回复版主是因为您的代码本身没有错,但不适用于这个网站。今天在坛友“网络书生”的帮助下,代码最终成功了。下面附上解决代码,请A版看看,是否还能优化,谢谢!
Global $httpObj, $guid, $file, $pz, $scwj, $data, $upfile, $fileSize
$httpObj = ObjCreate("winhttp.winhttprequest.5.1")
$upfile = "exe测试文件.exe"
$file = @ScriptDir & "\guid.txt";配置文件
$guid = guidjs();获取guid参数值
$pz = pzdata();获取pz参数值
$lasttime = _Hdate()
Local $boundary = '-----------------------------94922390417636' ;上传分隔线
Local $guid_bound = $boundary & @CRLF & _
'Content-Disposition: form-data; name="guid"' & @CRLF & @CRLF & $guid & @CRLF
$guid_bound = StringToBinary($guid_bound);二进制
Local $pz_bound = $boundary & @CRLF & _
'Content-Disposition: form-data; name="pz"' & @CRLF & @CRLF & $pz & @CRLF
$pz_bound = StringToBinary($pz_bound);二进制
Local $id_bound = $boundary & @CRLF & _
'Content-Disposition: form-data; name="id"' & @CRLF & @CRLF & "WU_FILE_0" & @CRLF
$id_bound = StringToBinary($id_bound);二进制
Local $name_bound = $boundary & @CRLF & _
'Content-Disposition: form-data; name="name"' & @CRLF & @CRLF & $upfile & @CRLF
$name_bound = StringToBinary($name_bound);二进制
Local $type_bound = $boundary & @CRLF & _
'Content-Disposition: form-data; name="type"' & @CRLF & @CRLF & "text/plain" & @CRLF
$type_bound = StringToBinary($type_bound);二进制
Local $lastModifiedDate_bound = $boundary & @CRLF & _
'Content-Disposition: form-data; name="lastModifiedDate"' & @CRLF & @CRLF & $lasttime & @CRLF
$lastModifiedDate_bound = StringToBinary($lastModifiedDate_bound);二进制
Local $file_bound = $boundary & @CRLF & _
'Content-Disposition: form-data; name="file"; filename="' & $upfile & '"' & @CRLF & _
'Content-Type: text/plain' & @CRLF & @CRLF
$file_bound = StringToBinary($file_bound);二进制
Local $hopen = FileOpen(@ScriptDir & "" & $upfile, 16);二进制读取文件
Local $binfile = FileRead($hopen)
FileClose($hopen)
Local $binfoot = @CRLF & $boundary & '--' & @CRLF ;最前的换行别忘了,"--"表示结束符
$binfoot = StringToBinary($binfoot);二进制
$data = $guid_bound & $pz_bound & $id_bound & $name_bound & $type_bound & $lastModifiedDate_bound & $size_bound & $file_bound & $binfile & $binfoot
;$data = $chars
FileWrite(FileOpen("test.txt", 2), $data)
FileClose("test.txt")
|