I just made this today for a program that I'm making, thought somebody here might be able to use it... The demo project has a rudimentary file browser to select an image, it then uploads it and places the image URL and the thumbnail URL in textboxes. The module is set up so you can use it however you want with no modifications, though.
Cool idea , this has been my to do list for some time but wasn't sure how to do it.
Using the code provided I uploaded one .PNG and one .GIF file to test, the Image URLs work but the Thumbnail Image URLs return a "404 - Not Found" page, which seems odd cause I went to their site and uploaded an image and the thumb URL is similar to the one the code returns. (.th.ext).
Last edited by Edgemeal; Jul 15th, 2008 at 06:35 AM.
Here's a module I created about 6 months ago. It allows you to upload images with Winsock and Inet. It returns all available links. I uploaded it to pscode as well, search for 'imageshack'.
::Edit::
Attachment removed. It doesn't work anymore.
Last edited by Chris001; Apr 16th, 2012 at 05:38 AM.
hai chris001
i am using your code in one of my program, but some time i get an error when uploading to image shack and program crashed. have you handled this error in yor code?
Run-time error '40006':
Wrong protocol or connection state for the requested transaction or request
oh sorry,
your aksing the location right,
after few uplaods only it happen. some time 2nd time, or 3rd time like after a upload complete and try to uplaod next one.
oh, thanks for your effort. i send an exe of your code today to the client who complained about the above error. he say your code works perfect.
so throughly searched my code for any diffrences form your impimentation.
finally i found a diffrent in my app. i had put a if condition in the connect event early to over come this error. so when it take that i works in his machine too now so now the problem is fixed and thank you for the effort and nice code.
Code:
Private Sub Winsock_Connect()
If Winsock.State = sckConnected Then
Dim arr() As String
If chkRandomName.Value Then
arr = PrepareImageUpload(txtImagePath.Text, m_Winsock, True) '// Create random image name
Else
arr = PrepareImageUpload(txtImagePath.Text, m_Winsock) '// Keep original image name
End If
Winsock.SendData arr(0) '// arr(0) = Header + Body in one piece
End If
End Sub
Private Sub Winsock_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
Winsock.Close
MsgBox Number & " - " & Description
End Sub
ImageShack have moved the location of the direct link form bottom to top. chris001 might not be aware of this i think. i just made a small change to my code. hope chris also would update his code.
my code.
Code:
' '// Direct link to image // The old code
' pos1 = InStr(pos2, strHTML, "width: 500px"" size=""70"" value=""")
' If pos1 Then
' pos2 = InStr(pos1, strHTML, """/>")
' If pos2 Then
' tmp = Mid$(strHTML, pos1 + 31, pos2 - (pos1 + 31))
' TempArray(7) = tmp
' End If
' End If
'// Direct link to image
pos1 = InStr(1, strHTML, "background-color: #DDDDAA;"" size=""70"" value=""")
If pos1 Then
pos2 = InStr(pos1, strHTML, """/>")
If pos2 Then
tmp = Mid$(strHTML, pos1 + 45, pos2 - (pos1 + 45))
TempArray(7) = tmp
End If
End If
It seems the data is redirected now. Inet handles redirections automatically, but Winsock doesn't.
Basically we need to strip the location from the header and visit that page to get all the links. Or perhaps create all the image links from the location url.
That's because ImageShack changed certain things again. They probably do that on purpose to prevent people from using scripts like this. That way you are forced to visit the website (with the ads) in order to upload images.
I don't really want to update the code anymore, because I'm not using it myself and it's too much work having to do it every week.
Last edited by Chris001; Jul 9th, 2009 at 04:47 PM.
Here's a module I created about 6 months ago. It allows you to upload images with Winsock and Inet. It returns all available links. I uploaded it to pscode as well, search for 'imageshack'.
Not work for me
Any one help me. I need understanding the winsock and inet upload in vb6.
Thanks!
The imageshack code is seriously outdated and doesn't work anymore, plus they nowhave video option as well, this form lacks these commands plus others.
My ImageShack code was already outdated two weeks after I posted it here (almost three years ago), because ImageShack keeps making changes regularly, to prevent people from using scripts like this.
I'm not going to update the code anymore, because I haven't programmed in VB6 for two years now. Moved to VB.NET.