CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 29
  1. #1
    Join Date
    Sep 2011
    Posts
    15

    Question VB6.0 Webbrowser Control Help with Uploading Image

    I have tried for hours researching and trial and error testing to get this to work, but I cannot figure it out or find an answer anywhere. I am hoping that someone here can help.

    I am trying to upload an image to a site through the webbrowser control. Here is the link to the page:

    http://toronto.kijiji.ca/c-SelectCategory?CatId=43

    When you click on the "Select Images" link, a dialog box pops up allowing to browse for the file. I have tried to get around this but can't. How can one manipulate the javascript to get an image uploaded?

    Code:
        Dim Doc As MSHTML.HTMLDocument
        Set Doc = WebBrowser1.document
        Set htmlinput = Doc.All.Item("Photo", 0)
        htmlinput.Value = "file:///D:/0KCeQp-1266425414.jpg"
    The above code will make an "image cannot be displayed" symbol appear in the upload image section. I am using IE9. However when you check out the properties of that file, it is not related to the file trying to be uploaded. The website's code looks like it is using a 3rd party site to upload images, however I keep getting lost in it and do not have the webbrowser control experience to figure this out. I am hoping someone here can help. Thanks.

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: VB6.0 Webbrowser Control Help with Uploading Image

    Looks like you have a few extra ///'s
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Sep 2011
    Posts
    15

    Question Re: VB6.0 Webbrowser Control Help with Uploading Image

    Doesn't make a difference. I tried various alternatives for the filename format. I stuck with file:///filename because this is what IE/MS Shell make a local file URL. It was the only one that worked. After your response, knowing what the result will be in advance, I tried it anyways, and sure enough it did not make a difference. I tried:

    Code:
    file:///d:\!1.jpg
    file://d:\!1.jpg
    file:/d:\!1.jpg
    file:d:\!1.jpg
    file:///d:/!1.jpg
    file://d:/!1.jpg
    file:d:/!1.jpg
    None make it work. And now that I am trying to reproduce the error, I can't even get the little red x "image cannot be displayed" icon to appear. Please help!

  4. #4
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: VB6.0 Webbrowser Control Help with Uploading Image

    This works in Fx:
    Code:
    file:///C:/temp/kmlchicagoparks.xml
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  5. #5
    Join Date
    Sep 2011
    Posts
    15

    Re: VB6.0 Webbrowser Control Help with Uploading Image

    Unfortunately this does not work. Please try to use my code at the specified URL and you will see what's going on. If your code works, please paste here because I have tried everything you've mentioned, and it does not work for me.

  6. #6
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: VB6.0 Webbrowser Control Help with Uploading Image

    I think you'd have to use SILVERLIGHT to use a selected file. Something about browser permission. FTP should work...
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  7. #7
    Join Date
    Sep 2011
    Posts
    15

    Re: VB6.0 Webbrowser Control Help with Uploading Image

    ***? Have you even looked at the site?

  8. #8
    Join Date
    Sep 2011
    Posts
    15

    Re: VB6.0 Webbrowser Control Help with Uploading Image

    There is no way for me to FTP to it. Shall I FTP my stuff to **** and Google while I'm at it?

  9. #9
    Join Date
    Sep 2011
    Posts
    15

    Re: VB6.0 Webbrowser Control Help with Uploading Image

    Not to mention Silverlight isn't even present on that domain. Excuse the above responses but it's getting really frustrating when you're the only one helping and you're not even looking at the page in question.

  10. #10
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: VB6.0 Webbrowser Control Help with Uploading Image

    Well, the site let me upload an image, then displayed it.
    Code:
    a dialog box pops up allowing to browse for the file. I have tried to get around this but can't
    I said the browser doesn't let websites grab files under ANY condition (other than it's own cookie)
    Code:
    FTP:\\serverinfo -s d:\temp\file.jpg u:xxx p:xxx
    That will let you log into a serve and send a file when the user clicks.
    Another EXPLORER command can open the FTP site in an Explorer window and drag and drop INTO it
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  11. #11
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: VB6.0 Webbrowser Control Help with Uploading Image

    I don't know much about automating user input for web sites and don't really care to learn but it looks to me like you are going about it wrong. You are referencing a hidden object by name and trying to trigger an upload yet the code seems to be using a different method.
    Code:
    var imageUpload = {
    			id : 'EPS',
    			enableFlash :true,
    			uploadUrl : 'http://api.classistatic.com/api/image/upload',
    			maxUploaders : 10,
    			dataField : 'Photo',
    			setId : '1C5000',
    			//EPS specific
    			thumbnailSizeId : '14',
    			epsVersion : '2',
    			defaultSizeId : '18',
    				removeText : 'Remove',
    			cancelText : 'Cancel',
    			retryText : 'Retry upload',
    			uploadingText : 'Image uploading',
    	        flash_button_width : 151,
    	        flash_button_height : 18,
    	        flash_button_text : '<span class="button">Select Images</span>',
    	        flash_button_text_style : '.button { font-family: Helvetica, Arial, sans-serif; font-size: 12pt;font-weight:bold;} .buttonSmall { font-size: 10pt; }',
    	        flash_button_text_top_padding : 1,
    	        flash_button_text_left_padding : 11,
    			errorTexts : errorTexts,
    			popupMsg : popupMsg
    			
    			,errorElement: "imageUpload_error"
    	};
    	
    	$(document).ready(function() {
    		if ( epsToken != '' ) {
    			//uploader.epsToken = epsToken;
    			$('#imageUpload').configEpsUploader(imageUpload);
    		} else {
    			$('#imageUpload').hide();
    		}
    	});
    Always use [code][/code] tags when posting code.

  12. #12
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: VB6.0 Webbrowser Control Help with Uploading Image

    Examples used JPG, so I uploaded and displayed an image. Trying to upload a FLASH MOVIE needs all kinds of specific server related parameters
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  13. #13
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: VB6.0 Webbrowser Control Help with Uploading Image

    The little piece of code I posted appears to be what the site is using to upload an image. It just happens to be using flash for display apparently.

    I'm not sure why the OP is trying to automate entry to the site and if it were my site I would do my best to prevent users from doing such a thing.
    Always use [code][/code] tags when posting code.

  14. #14
    Join Date
    Sep 2011
    Posts
    15

    Re: VB6.0 Webbrowser Control Help with Uploading Image

    Quote Originally Posted by dglienna View Post
    Well, the site let me upload an image, then displayed it.
    Code:
    a dialog box pops up allowing to browse for the file. I have tried to get around this but can't
    I said the browser doesn't let websites grab files under ANY condition (other than it's own cookie)
    Code:
    FTP:\\serverinfo -s d:\temp\file.jpg u:xxx p:xxx
    That will let you log into a serve and send a file when the user clicks.
    Another EXPLORER command can open the FTP site in an Explorer window and drag and drop INTO it

    You said this works for you. When my application is on the site using the webbrowser control, how do I make it upload the picture and appear in the uploaded picture list on the site? Can you please post your full solution? I don't understand what you mean.

  15. #15
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: VB6.0 Webbrowser Control Help with Uploading Image

    How about a picture?
    Attached Images Attached Images  
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Page 1 of 2 12 LastLast

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

Featured