Upload PictureBox to FTP

  • (2 Pages)
  • +
  • 1
  • 2

17 Replies - 2437 Views - Last Post: 25 December 2012 - 07:16 AM Rate Topic: -----

#1 Neph1x  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 125
  • Joined: 19-November 11

Upload PictureBox to FTP

Posted 24 December 2012 - 10:44 AM

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!
Is This A Good Question/Topic? 0
  • +

Replies To: Upload PictureBox to FTP

#2 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1067
  • View blog
  • Posts: 4,178
  • Joined: 02-July 08

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.
Was This Post Helpful? 1
  • +
  • -

#3 Neph1x  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 125
  • Joined: 19-November 11

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.
Was This Post Helpful? 0
  • +
  • -

#4 lar3ry  Icon User is offline

  • Coding Geezer
  • member icon

Reputation: 310
  • View blog
  • Posts: 1,290
  • Joined: 12-September 12

Re: Upload PictureBox to FTP

Posted 24 December 2012 - 11:28 AM

View PostNeph1x, 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.
Was This Post Helpful? 0
  • +
  • -

#5 trevster344  Icon User is offline

  • The Peasant
  • member icon

Reputation: 224
  • View blog
  • Posts: 1,511
  • Joined: 16-March 11

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
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

Was This Post Helpful? 1
  • +
  • -

#6 Neph1x  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 125
  • Joined: 19-November 11

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!

PictureBox1.Image.Save(IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "slika.jpg"))

Was This Post Helpful? 0
  • +
  • -

#7 trevster344  Icon User is offline

  • The Peasant
  • member icon

Reputation: 224
  • View blog
  • Posts: 1,511
  • Joined: 16-March 11

Re: Upload PictureBox to FTP

Posted 24 December 2012 - 12:08 PM

Username of the windows user?

If so then
Dim PathFileName as String = Application.StartupPath & "\" & SystemInformation.Username & "-" & Today.Date.ToShortDateString & ".jpg"


Was This Post Helpful? 1
  • +
  • -

#8 Neph1x  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 125
  • Joined: 19-November 11

Re: Upload PictureBox to FTP

Posted 24 December 2012 - 12:20 PM

and bellow that i add save code? yes?
Was This Post Helpful? 0
  • +
  • -

#9 trevster344  Icon User is offline

  • The Peasant
  • member icon

Reputation: 224
  • View blog
  • Posts: 1,511
  • Joined: 16-March 11

Re: Upload PictureBox to FTP

Posted 24 December 2012 - 12:23 PM

Yes that's just a string for the path, name, and extension.
Was This Post Helpful? 1
  • +
  • -

#10 Neph1x  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 125
  • Joined: 19-November 11

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?
Was This Post Helpful? 0
  • +
  • -

#11 Neph1x  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 125
  • Joined: 19-November 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!

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))

Was This Post Helpful? 0
  • +
  • -

#12 trevster344  Icon User is offline

  • The Peasant
  • member icon

Reputation: 224
  • View blog
  • Posts: 1,511
  • Joined: 16-March 11

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.
Was This Post Helpful? 0
  • +
  • -

#13 Neph1x  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 125
  • Joined: 19-November 11

Re: Upload PictureBox to FTP

Posted 24 December 2012 - 05:44 PM

Error...
Posted Image


And i'm not sure about that

Posted Image
Was This Post Helpful? 0
  • +
  • -

#14 trevster344  Icon User is offline

  • The Peasant
  • member icon

Reputation: 224
  • View blog
  • Posts: 1,511
  • Joined: 16-March 11

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.
Was This Post Helpful? 0
  • +
  • -

#15 Neph1x  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 125
  • Joined: 19-November 11

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
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2