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
Re: What's wrong with my code.
Could try giving us an idea of why you think something is wrong with your code...it'd help us help you
Re: What's wrong with my code.
hai smUx
i dont undestand German language :D
Code:
Could try giving us an idea of why you think something ....
btw, ill be back in 30 min :)
Re: What's wrong with my code.
http://translate.google.com/translate_t#
It's not rocket science here, if you have a problem there's a solution somewhere which gets you closer to understanding the bigger problem :-P
Re: What's wrong with my code.
smUX. ok ok kool.
Quote:
there's a solution somewhere
yes, hope here i can find it :thumb:
Re: What's wrong with my code.
Your Code:
imagepath = App.Path & "\" & "test.jpg"
My Code:
imagepath = App.Path & "\test.jpg"
Re: What's wrong with my code.
Quote:
Originally Posted by ThEiMp
Your Code:
imagepath = App.Path & "\" & "test.jpg"
My Code:
imagepath = App.Path & "\test.jpg"
Those will both give the same result.
But it would be a good idea to make sure that the "\" is needed.
Sometimes App.Path provides it but most times it doesn't.
Re: What's wrong with my code.
theEmp,
tx, but that is ok. no path problem in my code.
the file is open for binary access with out error.
Re: What's wrong with my code.
Yes that is right, there is nothing more wrong with your code and I don't see why it won't run. Could you please post a working demo of your source code onto this thread, so that we can see if that is totally correct?
1 Attachment(s)
Re: What's wrong with my code.
ofcause. give me a minute. ill attached it this this post it self.
Re: What's wrong with my code.
Well I cannot get it to work, but with the source code that I could get to work. I added into it a message box, loading box. Which means that it will go on when it is loading, eg: visible = True and when it is not loading it will be visible = False.
Re: What's wrong with my code.
ThEiMp,
is upload success and returns the results page in your test?
(which include the "Show Advanced Linking" keyword)