17 Replies - 552 Views - Last Post: 25 December 2012 - 07:16 AM
#1
Upload PictureBox to FTP
Posted 24 December 2012 - 10:44 AM
Please can you help me!, i need to upload directly image from picturebox to my ftp, but uploaded picture need to have other name!
Image to picturebox comming from screenshots, when i press F10 that my app take screenshot and need upload to ftp.
Thank you!
Replies To: Upload PictureBox to FTP
#2
Re: Upload PictureBox to FTP
Posted 24 December 2012 - 10:59 AM
#3
Re: Upload PictureBox to FTP
Posted 24 December 2012 - 11:15 AM
#4
Re: Upload PictureBox to FTP
Posted 24 December 2012 - 11:28 AM
Neph1x, on 24 December 2012 - 12:15 PM, said:
You know how, when you start typing in the code editor, you'll see choices listed?
For example, if you start typing the name of a control, you'll see your control listed below where you're typing. So if you double-click the line that has your PictureBox name in it, it will complete it for you. Then when you type a dot, it will again show you the choices. Notice that there is a choice in there of "Image". Double-click that line, and then type another dot. Have a look through the list to see if there is anything that looks like what you want to do with the image.
When you have clicked on that, type a "(" (without the quotes), and you'll see a box showing what you need to supply as an argument to that function.
Visual Studio is VERY helpful.
#5
Re: Upload PictureBox to FTP
Posted 24 December 2012 - 11:54 AM
if not:
Fundamentals
You'll need to look into using the FTPWebRequest and FTPWebResponse classes. They are optimal for FTP operations.
FTPWebRequest
FTPWebResponse
Now as for naming your pictures well I would suggest coming up with your own random name generator, and saving the picture from the picturebox(using the picturebox.save method) as a returned random name of a function to which will generate the name for you. We won't write code for you unfortunately here, you'll have to do that yourself, we can only give you ideas, tips, tricks, and articles to read up on.
An idea for random name would be
Private Function RandomGen() as String Dim RetString as String = String.Empty Dim Random as new Random() For i = 0 to 15 Dim int1 as integer = Random.next(0,15) select case int1 case 1 retstring &= "A" case 2 case 3 case 4 case 5 case 6 ... Next End Function
This post has been edited by trevster344: 24 December 2012 - 11:56 AM
#6
Re: Upload PictureBox to FTP
Posted 24 December 2012 - 12:05 PM
But you can maybe help me, how to get picture name but no random, i wanna use username,today date for name!
ma save code!
PictureBox1.Image.Save(IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "slika.jpg"))
#7
Re: Upload PictureBox to FTP
Posted 24 December 2012 - 12:08 PM
If so then
Dim PathFileName as String = Application.StartupPath & "\" & SystemInformation.Username & "-" & Today.Date.ToShortDateString & ".jpg"
#8
Re: Upload PictureBox to FTP
Posted 24 December 2012 - 12:20 PM
#9
Re: Upload PictureBox to FTP
Posted 24 December 2012 - 12:23 PM
#10
Re: Upload PictureBox to FTP
Posted 24 December 2012 - 01:01 PM
Dim PathFileName As String = Application.StartupPath & "\" & SystemInformation.UserName & "-" & Today.Date.ToShortDateString & ".jpg"
PictureBox1.Image.Save(IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), PathFileName))
do you mean something like that?
#11
Re: Upload PictureBox to FTP
Posted 24 December 2012 - 03:28 PM
this is upload code what i have!
Dim clsRequest As System.Net.FtpWebRequest = _
DirectCast(System.Net.WebRequest.Create("ftp://server"), System.Net.FtpWebRequest)
clsRequest.Credentials = New System.Net.NetworkCredential("users", "pass")
clsRequest.Method = System.Net.WebRequestMethods.Ftp.UploadFile
' read in file...
Dim bFile() As Byte = System.IO.File.ReadAllBytes[b](PathFileName)[/b]
' upload file...
Dim clsStream As System.IO.Stream = clsRequest.GetRequestStream()
clsStream.Write(bFile, 0, bFile.Length)
clsStream.Close()
clsStream.Dispose()
(PathFileName)
there is my file saved!
Dim PathFileName As String = Application.StartupPath & "\" & TextBox5.Text & "-" & Today.Date.ToShortDateString & "" & Label2.Text & ".jpg"
PictureBox1.Image.Save(IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), PathFileName))
#12
Re: Upload PictureBox to FTP
Posted 24 December 2012 - 03:58 PM
#13
Re: Upload PictureBox to FTP
Posted 24 December 2012 - 05:44 PM

And i'm not sure about that
#14
Re: Upload PictureBox to FTP
Posted 24 December 2012 - 06:25 PM
#15
Re: Upload PictureBox to FTP
Posted 24 December 2012 - 07:13 PM
FTP host name eagleeye.net46.net
FTP user name a4314365
FTP password *****
Folder to upload files public_html
|
|

New Topic/Question
Reply




MultiQuote





|