What's wrong with my code ?
i am uploading a file to image shack. i composted this code to my understanding by referring to http://www.vbforums.com/showpost.php...44&postcount=4
Code:Private Sub Command1_Click() Dim intFile As Integer '// Next available number for the Open statement Dim ImageData As String '// Image contents Dim Body As String '// Body contents Dim Header As String '// Header contents '// Get the image contents imagepath = App.Path & "\" & "test.jpg" ' max 3mb image size limited intFile = FreeFile Open imagepath For Binary As #intFile ImageData = String(LOF(intFile), Chr(0)) Get #intFile, , ImageData Close #intFile Body = "Content-Disposition: form-data; name=""fileupload""; filename=""" & vbCrLf Body = Body & "Content-Type: multipart/form-data" & vbCrLf Body = Body & vbCrLf & ImageData Header = "Host: imageshack.us" & vbCrLf Header = Header & "Content-Type: multipart/form-data & vbCrLf" Header = Header & "Content-Length: " & Len(ImageData) & vbCrLf & vbCrLf 'upload now Inet.Execute "http://www.imageshack.us", "POST", Body, Header While Inet.StillExecuting DoEvents Wend Dim s$, ret$ s = Inet.GetChunk(1024) Do Until s = "" ret = ret & s s = Inet.GetChunk(1024) Loop 'check upload completed If InStr(1, ret, "Show Advanced Linking") > 0 Then MsgBox "upload completed" End Sub




Reply With Quote