PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
[2005] A simple uploader-VBForums
Results 1 to 9 of 9

Thread: [2005] A simple uploader

  1. #1

    Thread Starter
    Addicted Member Cyberflyz's Avatar
    Join Date
    Apr 2007
    Location
    Utah
    Posts
    165

    [2005] A simple uploader

    Is there a way for me, to make a simple uploader to my site?

    User PC --> My website

    I want people to be able to upload images to my site, through an application I've made. I am using Visual Basic Express Edition 2005. My programming level is problem, just a little higher than Beginner.

    My hoster is Servage. They support Mysql databases, and multiple FTP accounts.

    If anymore information is needed, please just ask for it.

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    103,732

    Re: [2005] A simple uploader

    My.Computer.Network.UploadFile is the easiest way. You can also use WebClient.UploadFile or, for more complex situations, you can use FtpWebRequest/FtpWebResponse objects.

  3. #3

    Thread Starter
    Addicted Member Cyberflyz's Avatar
    Join Date
    Apr 2007
    Location
    Utah
    Posts
    165

    Re: [2005] A simple uploader

    Would you be able to explain in a little more complex way? Or show me some sample code? I have never, delt with anything like this.

  4. #4
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    103,732

    Re: [2005] A simple uploader

    That's what the MSDN library is for. Open the Help, search for my.computer.network.uploadfile, webclient.uploadfile, ftpwebrequest and ftpwebresponse and read. You then should post back if you don't understand how to implement what you've read.

  5. #5

    Thread Starter
    Addicted Member Cyberflyz's Avatar
    Join Date
    Apr 2007
    Location
    Utah
    Posts
    165

    Re: [2005] A simple uploader

    Here is the code I found,
    Code:
    ' Usage
    My.Computer.Network.UploadFile(sourceFileName ,address)
    My.Computer.Network.UploadFile(sourceFileName ,address)
    My.Computer.Network.UploadFile(sourceFileName ,address ,userName ,password)
    My.Computer.Network.UploadFile(sourceFileName ,address ,userName ,password)
    My.Computer.Network.UploadFile(sourceFileName ,address ,userName ,password ,showUI ,connectionTimeout)
    My.Computer.Network.UploadFile(sourceFileName ,address ,userName ,password ,showUI ,connectionTimeout ,onUserCancel)
    My.Computer.Network.UploadFile(sourceFileName ,address ,userName ,password ,showUI ,connectionTimeout)
    My.Computer.Network.UploadFile(sourceFileName ,address ,userName ,password ,showUI ,connectionTimeout ,onUserCancel)
    My.Computer.Network.UploadFile(sourceFileName ,address ,networkCredentials ,showUI ,connectionTimeout)
    My.Computer.Network.UploadFile(sourceFileName ,address ,networkCredentials ,showUI ,connectionTimeout ,onUserCancel)
    ' Declaration
    Public Sub UploadFile( _
       ByVal sourceFileName As String, _
       ByVal address As String _
    )
    ' -or-
    Public Sub UploadFile( _
       ByVal sourceFileName As String, _
       ByVal address As System.Uri _
    )
    ' -or-
    Public Sub UploadFile( _
       ByVal sourceFileName As String, _
       ByVal address As String, _
       ByVal userName As String, _
       ByVal password As String _
    )
    ' -or-
    Public Sub UploadFile( _
       ByVal sourceFileName As String, _
       ByVal address As System.Uri, _
       ByVal userName As String, _
       ByVal password As String _
    )
    ' -or-
    Public Sub UploadFile( _
       ByVal sourceFileName As String, _
       ByVal address As String, _
       ByVal userName As String, _
       ByVal password As String, _
       ByVal showUI As Boolean, _
       ByVal connectionTimeout As Integer _
    )
    ' -or-
    Public Sub UploadFile( _
       ByVal sourceFileName As String, _
       ByVal address As String, _
       ByVal userName As String, _
       ByVal password As String, _
       ByVal showUI As Boolean, _
       ByVal connectionTimeout As Integer, _
       ByVal onUserCancel As UICancelOption _
    )
    ' -or-
    Public Sub UploadFile( _
       ByVal sourceFileName As String, _
       ByVal address As System.Uri, _
       ByVal userName As String, _
       ByVal password As String, _
       ByVal showUI As Boolean, _
       ByVal connectionTimeout As Integer _
    )
    ' -or-
    Public Sub UploadFile( _
       ByVal sourceFileName As String, _
       ByVal address As System.Uri, _
       ByVal userName As String, _
       ByVal password As String, _
       ByVal showUI As Boolean, _
       ByVal connectionTimeout As Integer, _
       ByVal onUserCancel As UICancelOption _
    )
    ' -or-
    Public Sub UploadFile( _
       ByVal sourceFileName As String, _
       ByVal address As System.Uri, _
       ByVal networkCredentials As System.Net.ICredentials, _
       ByVal showUI As Boolean, _
       ByVal connectionTimeout As Integer _
    )
    ' -or-
    Public Sub UploadFile( _
       ByVal sourceFileName As String, _
       ByVal address As System.Uri, _
       ByVal networkCredentials As System.Net.ICredentials, _
       ByVal showUI As Boolean, _
       ByVal connectionTimeout As Integer, _
       ByVal onUserCancel As UICancelOption _
    )
    How do I allow, the user to choose the file uploaded, and Can I make it so only certain file types are allowed, like Jpeg things like that?

  6. #6
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    103,732

    Re: [2005] A simple uploader

    UploadFile uploads whatever file you tell it to. Those other questions have nothing to do with uploading the file. Selecting which file(s) to upload is unrelated.

    If you want the user to select a folder then you would use a FolderBrowserDialog. You can then call IO.Directory.GetFiles to get all the paths of all the files in that folder, specifying a filter if you wish.

    If you want the user to select a single file then you'd use an OpenFileDialog. You can set its Filter property to only display files of certain types if you wish.

  7. #7

    Thread Starter
    Addicted Member Cyberflyz's Avatar
    Join Date
    Apr 2007
    Location
    Utah
    Posts
    165

    Re: [2005] A simple uploader

    I'm a little confused....could you please explain the first steps I need to complete?

  8. #8
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    103,732

    Re: [2005] A simple uploader

    I already did:
    If you want the user to select a folder then you would use a FolderBrowserDialog. You can then call IO.Directory.GetFiles to get all the paths of all the files in that folder, specifying a filter if you wish.

    If you want the user to select a single file then you'd use an OpenFileDialog. You can set its Filter property to only display files of certain types if you wish.
    You've been given two classes, a method and a property. Have you read the MSDN documentation for each yet? If not then that will help you dispel the confusion.

  9. #9
    Frenzied Member Motoxpro's Avatar
    Join Date
    Sep 2001
    Location
    Spiro, OK
    Posts
    1,211

    Re: [2005] A simple uploader

    you could try somthing like
    vb Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         Dim Address As String = "http://YourWebAddress.com"
    3.         Dim iResult As DialogResult
    4.         OpenFileDialog1.Title = "Choose a File to Open"
    5.         'Set the this to your liking
    6.         OpenFileDialog1.Filter = "Text File (*.txt) | *.txt"
    7.         OpenFileDialog1.AddExtension = True
    8.         OpenFileDialog1.InitialDirectory = "C:\"
    9.         OpenFileDialog1.FileName = ""
    10.         iResult = OpenFileDialog1.ShowDialog()
    11.         If iResult <> Windows.Forms.DialogResult.Cancel And _
    12.                     OpenFileDialog1.FileName.Length <> 0 Then
    13.             My.Computer.Network.UploadFile(OpenFileDialog1.filename, Address)
    14.         End If
    15.     End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width