|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
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
|
|||
|
|||
|
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. |
|
#2
|
|||
|
|||
|
Some Knowledge about upload:
http://www.winnetmag.com/Articles/I...m?ArticleID=565 |
|
#3
|
|||
|
|||
|
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. |
|
#4
|
|||
|
|||
|
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 |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > Posting Image files with WebBrowser or Inet? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|