SunQuest
           Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th-1:00PM EST. Register Today!
  #1  
Old September 16th, 2003, 06:28 AM
floaterfan floaterfan is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 2 floaterfan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question How do I post Image files with WebBrowser or Inet?

I hope this is the right place to ask this questions.

Here is my dilemma:
I need to post an image file from Visual Basic to an existing server. I tried to just set the value of the filename but I know this is not possible because the input is type=file, which means that the Value property is read only for security reasons. So now I need to know how to post the data to the site with either the webbrowser control or the inet control. I don’t care which but if it’s the inet control I will need to know how to extract the form data like I have done with the webbrowser control.

Scenario:
Step 1: Login in to the web site that I will need to upload images to.
Seep 2: Navigate to image loading page.
Step 3: Extract form data.
Step 4: Encode Data - I need help with this
Step 5: Post Data - I need help with this

My first question is do I need to encode just the image path, or do I need to encode the actual image data?

My second question is how do I post the data?

Here is the HTML from the form that I want to post to.
******************************************************
Code:
<form name="upload1" action="http://xxxServerxxx/manimage.asp" method="POST" enctype="multipart/form-data">
<input type="hidden" name="cmd" value="savefile">
<input type="hidden" name="sku" value="448755">
<input type="hidden" name="pid" value="505705">
<input type="hidden" name="func" value="savefile">
<input type="hidden" name="randomnumber" value="434896073610">
<span class="t1">Filename:<br>
<input type="file" name="filename" size="18" class="i3" style="width:250px"><p>
<input type="submit" name="uploadfile" value="Click Here To Upload Image" class="sub1">
</form>

******************************************************

Here is the start of some VB code
******************************************************
web = the name of my webbrowser control

Code:
Private Function postImages()

Dim strCMD, strSKU, strPID, strFUNC, strand as String
Dim strPostData, strImgPath as String
Dim bytPostData() as Byte
Dim varPostData as Variant

      strCMD = web.document.upload1.cmd.Value
      strSKU = web.document.upload1.sku.Value
      strPID = web.document.upload1.pid.Value
      strFUNC = web.document.upload1.func.Value
      strRAND = web.document.upload1.randomnumber.Value

       strImgPath = "F:\YRGVB\LMS\img\myimg.jpg"

    	strPostData = "cmd=" & strCMD & _
                    "&sku=" & strSKU & _
                    "&pid=" & strPID & _
                    "&func=" & strFUNC & _
                    "&randomnumber=" & strRAND & _
                    "&filename=" & strImgPath

	strHeader = "????????????????????????????????????"

	'Do some type of encoding with strPostData and set to bytPostData   ????? 
	encodePostData(bytPostData, strPostData)

	'set varPostData to bytPostData						  ?????
	varPostData = bytPostData
	
          web.navigate "http://xxxServerxxx/manimage.asp", 0, "", varPostData, strHeader

End Function

Private Sub encodePostData(ByRef ByteArray() As Byte, ByVal strPostData As String)

'I don’t know what to do here

End Sub


Please help with the encoding, again I don’t know if I should encode the file path or the actual file.

Please help with the headers and the posting.

Any help is appreciated.
Thanks,
Sam

Last edited by floaterfan : September 16th, 2003 at 05:01 PM.

Reply With Quote
  #2  
Old September 17th, 2003, 01:00 AM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via MSN to cleverpig

Reply With Quote
  #3  
Old September 17th, 2003, 02:37 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 12th Plane (10500 - 10999 posts)
 
Join Date: Jun 2003
Posts: 10,687 Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 4 Weeks 1 Day 16 h 39 m 15 sec
Reputation Power: 688
Is FTP out of the question? The Internet Transfer Control (sometimes flakey) supports ftp transfers, and there are some free 3rd party ftp controls floating around too.

I don't know how to manipulate the header to post your file automatically using the web browser control.

Reply With Quote
  #4  
Old September 23rd, 2003, 03:07 PM
floaterfan floaterfan is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 2 floaterfan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thank you for your input

Cleverpig - Thank you for the link, I figured out the headers by catching the post data with the Webbrowser control, but I still do not know how the data is encoded.

Doug G - Thank you, but ftp will not work for this.

Sam

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Posting Image files with WebBrowser or Inet?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway