Results 1 to 28 of 28

Thread: VB6 - Imageshack upload module

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2007
    Posts
    4

    VB6 - Imageshack upload module

    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.
    Attached Files Attached Files

  2. #2
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: VB6 - Imageshack upload module

    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.

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2007
    Posts
    4

    Re: VB6 - Imageshack upload module

    I'm not sure, actually. I got that with one of my files, but it only happens with that one.

  4. #4
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,834

    Re: VB6 - Imageshack upload module

    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.

  5. #5
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: VB6 - Imageshack upload module

    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

  6. #6
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,834

    Re: VB6 - Imageshack upload module

    Can you tell me where that error exactly occurs?

  7. #7
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: VB6 - Imageshack upload module

    Hai chris001,
    Thanks for comming back to this old thread again.
    i was using your winsock code and on some pc's gettign this error
    Last edited by Fazi; Feb 17th, 2009 at 01:18 PM.

  8. #8
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: VB6 - Imageshack upload module

    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.

  9. #9
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,834

    Re: VB6 - Imageshack upload module

    Where in de code does the error occur? On which line?

  10. #10
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: VB6 - Imageshack upload module

    sorry for the late,
    it here
    Code:
    Winsock.Connect "imageshack.us", 80
    so after a google search i put this code before abouve code
    Code:
    Do Until Winsock.State = 0
        DoEvents
        If Winsock.State > 7 Then Winsock.Close
    Loop
    it fixed in my machine, but one my custommer keep getting that error. i still could not get in to his pc to check the error

  11. #11
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,834

    Re: VB6 - Imageshack upload module

    I ran my code in a continuous loop, but I'm unable to reproduce that error.

    Did you make any changes to the code that might cause that error?

  12. #12
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: VB6 - Imageshack upload module

    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
    I Removed the red color code now and working.

  13. #13
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: VB6 - Imageshack upload module



    I have not included this in my project
    Code:
    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
    Resolved
    Last edited by Fazi; Feb 19th, 2009 at 10:56 PM.

  14. #14
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: VB6 - Imageshack upload module

    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

  15. #15
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,834

    Re: VB6 - Imageshack upload module

    You're right, thanks Fazi. The 'Direct' and 'Hotlink for Websites' links didn't work anymore.

    Code updated.

    http://www.vbforums.com/showpost.php...44&postcount=4

  16. #16
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: VB6 - Imageshack upload module

    Ooops,
    winsock uploading today not working

  17. #17
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,834

    Re: VB6 - Imageshack upload module

    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.

    Code:
    HTTP/1.0 302 Found
    X-Powered-By: PHP/5.2.4
    Set-Cookie: PHPSESSID=9tvvcnnpm8d77e9orn90rvae31; path=/
    Set-Cookie: imgshck=9tvvcnnpm8d77e9orn90rvae31; expires=Tue, 02-Mar-2010 14:42:06 GMT; path=/; domain=.imageshack.us
    Set-Cookie: un_cookie=1; expires=Sun, 08-Mar-2009 14:42:06 GMT; path=/; domain=.imageshack.us
    Set-Cookie: latest=img10; expires=Tue, 02-Mar-2010 14:42:06 GMT; path=/; domain=.imageshack.us
    Set-Cookie: conversion=deleted; expires=Fri, 07-Mar-2008 14:42:05 GMT; path=/; domain=.imageshack.us
    Set-Cookie: always_opt=-1; path=/; domain=.imageshack.us
    Set-Cookie: rem_bar=-1; path=/; domain=.imageshack.us
    Expires: Thu, 19 Nov 1981 08:52:00 GMT
    Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
    Pragma: no-cache
    location: http://img10.imageshack.us/content.php?page=done&l=img10/7986/4h3jb.png
    Content-type: text/html
    Content-Length: 1
    Connection: close
    Date: Sat, 07 Mar 2009 14:42:06 GMT
    Server: lighttpd/1.5.0

  18. #18
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: VB6 - Imageshack upload module

    Thanks chris001 for the update,
    ill check it.

  19. #19
    New Member
    Join Date
    Mar 2009
    Location
    Bhubaneswar
    Posts
    14

    Re: VB6 - Imageshack upload module

    Hi, Chris001 brother

    I want a code like imageshack project..

    suppose imageshack is my web server, i want PHP code written in server side which helps to upload images to that specified web folder..

    using your imageshack project, i was just modified, given below , but unsuccessful..

    Please help me ...

    // IN Index.PHP
    //---------------------------------------------------------------------------
    <title>FILE UPLOAD</title>
    <form enctype="multipart/form-data" action="upload.php" method="POST">
    <input type="hidden" name="MAX_FILE_SIZE" value="100000" />
    Choose a file to upload: <input name="fileupload" type="file" /><br />
    <input type="submit" value="Upload" />
    </form>
    //---------------------------------------------------------------------------

    // IN upload.php -----------
    //--------------------------------------------------------------------

    <title>DONE</title>
    <?php
    $target_path = "uploads/";
    $Fpath=$_FILES['fileupload']['name'];
    $target_path = $target_path . basename($Fpath);
    $tmpPath=$_FILES['uploader']['tmp_name'];
    if(move_uploaded_file($tmpPath, $target_path)) {
    echo "The file ". basename($Fpath).
    " has been uploaded";
    } else{
    echo "There was an error uploading the file, please try again!";
    }
    ?>

    //---------------------------------------------------------------------

    // VB Code is Imageshack...

    I was changed imageshack project code to following code

    example 1: [ Inet.Execute "http://www.xyzdomain.com", "POST", arr(0), arr(1) '// arr(0) = Body and arr(1) = Header ]

    In module also
    example 2: [ Header = Header & "Host: xyzdomain.com" & vbCrLf ]


    I WANT TO UPLOAD ANY FILE TO MY WEB SERVER USING VB PROJECT (INET CONTROL)

    I have linux web server

    rectify my coding , and solve it
    please , please please , give me the COde...


    Advance Thanks....
    Waiting

  20. #20
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,834

    Re: VB6 - Imageshack upload module

    Sorry, but I can't help you with that. My PHP knowledge is 0,0000 nothing.

    I can only help you with VB.

  21. #21
    Lively Member
    Join Date
    Dec 2006
    Posts
    124

    Re: VB6 - Imageshack upload module

    i tried the updated code, but the direct link wont work for me when i use the inet control

  22. #22
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,834

    Re: VB6 - Imageshack upload module

    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.

  23. #23
    Hyperactive Member
    Join Date
    Aug 2008
    Posts
    382

    Re: VB6 - Imageshack upload module

    Is that Remort Port is same for every website
    here is the some part of your coding.....
    vb Code:
    1. winsockCtl.Protocol = sckTCPProtocol
    2.     winsockCtl.RemoteHost = "www.imageshack.us"
    3.     winsockCtl.RemotePort = 80
    4.     winsockCtl.Connect

  24. #24
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,834

    Re: VB6 - Imageshack upload module

    Yes, port 80 is the standard port for websites.

  25. #25
    Hyperactive Member
    Join Date
    Aug 2008
    Posts
    382

    Re: VB6 - Imageshack upload module

    thanks I will Go through this code and if i will facing any problem i will asked

    thanks

  26. #26
    New Member
    Join Date
    Mar 2012
    Posts
    1

    Re: VB6 - Imageshack upload module

    Quote Originally Posted by Chris001 View Post
    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!

  27. #27
    Hyperactive Member jokerfool's Avatar
    Join Date
    Dec 2006
    Location
    Gold Coast, Australia
    Posts
    452

    Re: VB6 - Imageshack upload module

    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.

  28. #28
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,834

    Re: VB6 - Imageshack upload module

    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.

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