FTP Uploader[Not .TXT - image]

Do you need something made? then ask in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
7 posts Page 1 of 1
Contributors
User avatar
NecroPhis
VIP - Donator
VIP - Donator
Posts: 345
Joined: Sun Aug 08, 2010 1:14 pm

FTP Uploader[Not .TXT - image]
NecroPhis
he i want to upload some images to my website with my program

i used ftp chat's tutorial
Code: Select all
  Try
            Dim client As New Net.WebClient
            client.Credentials = New Net.NetworkCredential("xxx", "xxx")
            client.UploadString("ftp://nexonsux.megabyte.net/" & TextBox1.Text, ofd.FileName)
            MsgBox("Image Uploaded", MsgBoxStyle.Information)
        Catch ex As Exception
            MsgBox("Image Could Not Upload", MsgBoxStyle.Critical, "Error!")
        End Try
but mm it failed :(
so i need your help thanx,,
Image
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: FTP Uploader[Not .TXT - image]
mandai
Check out http://msdn.microsoft.com/en-us/library/ms229715.aspx

UploadString is usually only used in HTTP requests, not FTP.
User avatar
NecroPhis
VIP - Donator
VIP - Donator
Posts: 345
Joined: Sun Aug 08, 2010 1:14 pm

Re: FTP Uploader[Not .TXT - image]
NecroPhis
i am getting this error : This language is not supported or no code example is available.
Image
User avatar
Scottie1972
Codenstuff Elite
Codenstuff Elite
Posts: 953
Joined: Thu Jan 14, 2010 5:48 am

NecroPhis wrote:
i am getting this error : This language is not supported or no code example is available.
Yeah I even used a C3 to VB converter software ( http://converter.telerik.com/ )
I even tried it on a few diffrerent website and it wasnt able to be converted do to some line error within the code.

If you just need a code snippet that will upload via FTP

Try this
Code: Select all
 ' set up request...
       Dim clsRequest As System.Net.FtpWebRequest = DirectCast(System.Net.WebRequest.Create("ftp://SOMEFTPSITE.COM/somefilename.txt), System.Net.FtpWebRequest)

'THIS IS A MUST. You must have a FTP User's Account login information
        clsRequest.Credentials = New System.Net.NetworkCredential("USERNAME", "PASSWORD")
        clsRequest.Method = System.Net.WebRequestMethods.Ftp.UploadFile

        ' read in file...
        Dim bFile() As Byte = System.IO.File.ReadAllBytes(filepath)

        ' upload file...
        Dim clsStream As System.IO.Stream = clsRequest.GetRequestStream()
        clsStream.Write(bFile, 0, bFile.Length)
        clsStream.Close()
        clsStream.Dispose()
Image
User avatar
NecroPhis
VIP - Donator
VIP - Donator
Posts: 345
Joined: Sun Aug 08, 2010 1:14 pm

Re: FTP Uploader[Not .TXT - image]
NecroPhis
2 errors:
Code: Select all
clsRequest.Credentials = New System.Net.NetworkCredential("USERNAME", "PASSWORD")
        clsRequest.Method = System.Net.WebRequestMethods.Ftp.UploadFile
Image
User avatar
Scottie1972
Codenstuff Elite
Codenstuff Elite
Posts: 953
Joined: Thu Jan 14, 2010 5:48 am

NecroPhis wrote:
2 errors:
Code: Select all
clsRequest.Credentials = New System.Net.NetworkCredential("USERNAME", "PASSWORD")
        clsRequest.Method = System.Net.WebRequestMethods.Ftp.UploadFile

Did you read the line just above that?
It said.
'THIS IS A MUST. You must have a FTP User's Account login information
clsRequest.Credentials = New System.Net.NetworkCredential("USERNAME", "PASSWORD")
clsRequest.Method = System.Net.WebRequestMethods.Ftp.UploadFile

This means where "USERNAME" and "PASSWORD" is, you replace "USERNAME" and "PASSWORD" with your ftp username and password

example:
ftp://someftpsite.com
then a window will hask you for a Username and a Password.
The ftp Username and Password that you use to access the ftp site is what you would use in the section that says "USERNAME" and "PASSWORD"


Those "2 Errors" came from you not filling in the "USERNAME" and "PASSWORD" for the ftp site that you are trying to access.
Image
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4392
Joined: Tue Aug 04, 2009 1:47 am

Hello,

You cant just use the quickest way?:
Code: Select all
My.Computer.Network.UploadFile("NameOfFileToUpload.ext", "ftp://www.YOURSITE.com/NameOfFileToSaveItAs.ext", "USERNAME", "PASSWORD", True, 10, FileIO.UICancelOption.DoNothing)
Works ok for me with any file type cooll; .
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
7 posts Page 1 of 1
Return to “Tutorial Requests”