Results 1 to 7 of 7

Thread: [RESOLVED] Upload File To WebServer FTP

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2009
    Location
    Scotland/Japan
    Posts
    164

    Resolved [RESOLVED] Upload File To WebServer FTP

    Ok Im Building a file storage application that saves images to a web server but I have come across an issue how do i go about uploading the files to the server how do i go about useing FTP inside of a vb application

    An Example....

    I have a button that opens a file select dialog you select the file it puts the location in a text box then theres a button that you click and it uploads that file to the folder on the web server.....

    Im Unsure how to do this it seems simple in theory but allot harder in real practice
    Between the world we see and the things we fear theres a realm of possibility

    D.L.H. Ind.

    We do what we do in out life to make Yours Simpler

  2. #2

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jul 2009
    Location
    Scotland/Japan
    Posts
    164

    Re: Upload File To WebServer FTP

    yea i tryed that but i am getting an error

    vb Code:
    1. Option Strict Off
    2. Imports System.Net
    3.  
    4. Module Module1
    5.  
    6.     Sub Main()
    7.         Dim intChunk As Integer
    8.         Dim intoffset As Integer
    9.         Dim clsRequest As System.Net.FtpWebRequest = _
    10.             DirectCast(System.Net.WebRequest.Create("ftp://dlh-digital.com/public_html/images/ftptest"), System.Net.FtpWebRequest)
    11.         clsRequest.Credentials = New System.Net.NetworkCredential("username", "password")
    12.         clsRequest.Method = System.Net.WebRequestMethods.Ftp.UploadFile
    13.  
    14.         ' read in file...
    15.         Dim bFile() As Byte = System.IO.File.ReadAllBytes(Form5.TextBox2.Text)
    16.  
    17.         ' upload file...
    18.         Dim clsStream As System.IO.Stream = clsRequest.GetRequestStream()
    19.         intChunk = bFile.Length / 100
    20.         Form5.pbUpload.Maximum = 100
    21.         For I As Integer = 1 To 100
    22.             If intOffset + intChunk > bFile.Length Then intChunk = bFile.Length - intOffset
    23.             clsStream.Write(bFile, intOffset, intChunk)
    24.             intOffset += intChunk
    25.             Form5.pbUpload.Value = I
    26.         Next
    27.         clsStream.Close()
    28.         clsStream.Dispose()
    29.     End Sub
    30.  
    31. End Module

    but on this line it errors on me
    Dim clsStream As System.IO.Stream = clsRequest.GetRequestStream()

    with the error code

    The remote server returned an error: (553) File name not allowed.

    ware am i going wrong....
    Between the world we see and the things we fear theres a realm of possibility

    D.L.H. Ind.

    We do what we do in out life to make Yours Simpler

  4. #4
    PowerPoster cicatrix's Avatar
    Join Date
    Dec 2009
    Location
    Moscow, Russia
    Posts
    3,654

    Re: Upload File To WebServer FTP

    What is the filename? What do you type in Form5.TextBox2.Text?

    Is there such a file on a disk? If it exists then try to upload this file using some ftp client

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jul 2009
    Location
    Scotland/Japan
    Posts
    164

    Re: Upload File To WebServer FTP

    yes... textbox2.text is filled by the location of the file selected from the file select dialog...

    and its anyfile i try to upload with every extention so i think theres sometihng wrong someware.....
    Between the world we see and the things we fear theres a realm of possibility

    D.L.H. Ind.

    We do what we do in out life to make Yours Simpler

  6. #6
    PowerPoster cicatrix's Avatar
    Join Date
    Dec 2009
    Location
    Moscow, Russia
    Posts
    3,654

    Re: Upload File To WebServer FTP

    Did you try to upload this file using ordinary ftp client?
    The issue may be in the ftp server itself, not your code.
    Get a WORKING ftp client here

    Try to upload this very file using the FTP client. Check if the server accepts it.

    And does your filename contain some unusual characters? Try to rename it to 1.dat for example and try again. The remote system might not allow some unusual characters in the filename.
    (mind the fact that a whitespace may be changed to %20 in the process and a percent sign % may cause troubles).

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Jul 2009
    Location
    Scotland/Japan
    Posts
    164

    Re: Upload File To WebServer FTP

    Ummmmm Yes it takes the files via filezilla....

    so its not that the server dont like the file theres something else wrong with the code or something what im note sure
    Between the world we see and the things we fear theres a realm of possibility

    D.L.H. Ind.

    We do what we do in out life to make Yours Simpler

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