Results 1 to 12 of 12

Thread: What's wrong with my code.

Threaded View

  1. #1

    Thread Starter
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    What's wrong with my code.

    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
    Last edited by Fazi; Oct 18th, 2008 at 08:34 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width