Hey!
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!
17 Replies - 505 Views - Last Post: 25 December 2012 - 07:16 AM
Replies To: Upload PictureBox to FTP
#2
Re: Upload PictureBox to FTP
Posted 24 December 2012 - 10:59 AM
FTP transfers files. Make a file from the image and then upload that.
#3
Re: Upload PictureBox to FTP
Posted 24 December 2012 - 11:15 AM
I don't know how to do it :$ yes, i know how to save using savefiledialog but i wanna doing this automaticlly.
#4
Re: Upload PictureBox to FTP
Posted 24 December 2012 - 11:28 AM
Neph1x, on 24 December 2012 - 12:15 PM, said:
I don't know how to do it :$ yes, i know how to save using savefiledialog but i wanna doing this automaticlly.
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
Nephix it seems to me that you need to do more research friend. Assuming you have a solid understanding of the fundamentals of Object oriented programming
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
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
It is resolved, but Thank you!
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!
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
Username of the windows user?
If so then
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
and bellow that i add save code? yes?
#9
Re: Upload PictureBox to FTP
Posted 24 December 2012 - 12:23 PM
Yes that's just a string for the path, name, and extension.
#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
ok after i make a file from the image how can i upload it?
this is upload code what i have!
(PathFileName)
there is my file saved!
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
Well you need a server you want to send it too. Either a URL or an IP Address. Have you tried that with a valid url? If so what happened, any errors? Let me know.
#13
Re: Upload PictureBox to FTP
Posted 24 December 2012 - 05:44 PM
Error...

And i'm not sure about that

And i'm not sure about that
#14
Re: Upload PictureBox to FTP
Posted 24 December 2012 - 06:25 PM
Did you look into the uri? The error is pretty straight forward I can't really help ya there.
#15
Re: Upload PictureBox to FTP
Posted 24 December 2012 - 07:13 PM
Here are my FTP details. This is free web hosting.
FTP host name eagleeye.net46.net
FTP user name a4314365
FTP password *****
Folder to upload files public_html
FTP host name eagleeye.net46.net
FTP user name a4314365
FTP password *****
Folder to upload files public_html
|
|

New Topic/Question
Reply




MultiQuote




|