Page 1 of 1
FTP Uploader[Not .TXT - image]
Posted: Sat Sep 18, 2010 9:12 pm
by 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,,
Re: FTP Uploader[Not .TXT - image]
Posted: Sat Sep 18, 2010 9:47 pm
by mandai
Check out
http://msdn.microsoft.com/en-us/library/ms229715.aspx
UploadString is usually only used in HTTP requests, not FTP.
Re: FTP Uploader[Not .TXT - image]
Posted: Sat Sep 18, 2010 10:13 pm
by NecroPhis
i am getting this error : This language is not supported or no code example is available.
Re: FTP Uploader[Not .TXT - image]
Posted: Sat Sep 18, 2010 10:32 pm
by Scottie1972
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()
Re: FTP Uploader[Not .TXT - image]
Posted: Sat Sep 18, 2010 10:34 pm
by NecroPhis
2 errors:
Code: Select allclsRequest.Credentials = New System.Net.NetworkCredential("USERNAME", "PASSWORD")
clsRequest.Method = System.Net.WebRequestMethods.Ftp.UploadFile
Re: FTP Uploader[Not .TXT - image]
Posted: Sat Sep 18, 2010 11:33 pm
by Scottie1972
NecroPhis wrote:2 errors:
Code: Select allclsRequest.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.
Re: FTP Uploader[Not .TXT - image]
Posted: Sun Sep 19, 2010 2:14 am
by CodenStuff
Hello,
You cant just use the quickest way?:
Code: Select allMy.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; .