-
1 Attachment(s)
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.
-
Re: VB6 - Imageshack upload module
Cool idea :thumb:, 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).
-
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.
-
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.
-
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
-
Re: VB6 - Imageshack upload module
Can you tell me where that error exactly occurs?
-
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
http://img8.imageshack.us/img8/3868/screenshotbq6.jpg
-
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.
-
Re: VB6 - Imageshack upload module
Where in de code does the error occur? On which line?
-
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 :(
-
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?
-
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.
-
Re: VB6 - Imageshack upload module
http://www.vbforums.com/http://www.vbforums.com/http://www.vbforums.com/http://www.vbforums.com/http://www.vbforums.com/
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 :check:
-
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
-
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
-
Re: VB6 - Imageshack upload module
Ooops,
winsock uploading today not working :(
-
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
-
Re: VB6 - Imageshack upload module
Thanks chris001 for the update,
ill check it.
-
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
-
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.
-
Re: VB6 - Imageshack upload module
i tried the updated code, but the direct link wont work for me when i use the inet control
-
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.
-
Re: VB6 - Imageshack upload module
Is that Remort Port is same for every website
here is the some part of your coding.....
vb Code:
winsockCtl.Protocol = sckTCPProtocol
winsockCtl.RemoteHost = "www.imageshack.us"
winsockCtl.RemotePort = 80
winsockCtl.Connect
-
Re: VB6 - Imageshack upload module
Yes, port 80 is the standard port for websites.
-
Re: VB6 - Imageshack upload module
thanks I will Go through this code and if i will facing any problem i will asked
thanks
-
Re: VB6 - Imageshack upload module
Quote:
Originally Posted by
Chris001
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!
-
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.
-
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.