Upload file via PHP upload form.

Please support our VB.NET advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jun 2008
Posts: 3
Reputation: dab is an unknown quantity at this point 
Solved Threads: 0
dab dab is offline Offline
Newbie Poster

Upload file via PHP upload form.

 
0
  #1
Jun 29th, 2008
I'm trying to upload a file to my PHP form on my website. I have no idea how to go about this. I'm sure I need to break down the file into a transferable form, I'm not sure where to go about this. Then I need to send an HTTP request to it, but I'm not sure either.

The website I'm uploading to is: http://download.dab-media.com/
I know the upload isn't perfect, but I just wanted to do it for learning purposes, and this shall extend my learning purposes yet.

I've searched Google all over, and can't seem to find anything that works, or is just too confusing to setup. :\
Any links, or anything will be helpful.
Thanks!
dab.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2,641
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Solved Threads: 245
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Posting Maven

Re: Upload file via PHP upload form.

 
0
  #2
Jun 30th, 2008
Post your question on PHP Section. This section just for VB.Net
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 3
Reputation: dab is an unknown quantity at this point 
Solved Threads: 0
dab dab is offline Offline
Newbie Poster

Re: Upload file via PHP upload form.

 
0
  #3
Jun 30th, 2008
Oh snap, I forgot to tell you why its in the vb.net section. I'm trying to make an application upload an image to my php form, from the application. Such as the user selects an image, and the application will upload the image to the website.
I've looked through Google, and found some code to connect to a page, however, I'm not sure how to "upload" the image to the page. I've looked, and found a thing talking about converting it to bytes or something... Not 100% sure to do here. :\
  1. Private Shared Sub start_post()
  2. 'Our postvars
  3. Dim buffer As Byte() = Encoding.ASCII.GetBytes("test=postvar&test2=another")
  4. 'Initialisation, we use localhost, change if appliable
  5. Dim WebReq As HttpWebRequest = DirectCast(WebRequest.Create("http://download.dab-media.com/test.php"), HttpWebRequest)
  6. 'Our method is post, otherwise the buffer (postvars) would be useless
  7. WebReq.Method = "POST"
  8. 'We use form contentType, for the postvars.
  9. WebReq.ContentType = "application/x-www-form-urlencoded"
  10. 'The length of the buffer (postvars) is used as contentlength.
  11. WebReq.ContentLength = buffer.Length
  12. 'We open a stream for writing the postvars
  13. Dim PostData As Stream = WebReq.GetRequestStream()
  14. 'Now we write, and afterwards, we close. Closing is always important!
  15. PostData.Write(buffer, 0, buffer.Length)
  16. PostData.Close()
  17. 'Get the response handle, we have no true response yet!
  18. Dim WebResp As HttpWebResponse = DirectCast(WebReq.GetResponse(), HttpWebResponse)
  19. 'Let's show some information about the response
  20. Console.WriteLine(WebResp.StatusCode)
  21. Console.WriteLine(WebResp.Server)
  22.  
  23. 'Now, we read the response (the string), and output it.
  24. Dim Answer As Stream = WebResp.GetResponseStream()
  25. Dim _Answer As New StreamReader(Answer)
  26. Console.WriteLine(_Answer.ReadToEnd())
  27.  
  28. 'Congratulations, you just requested your first POST page, you
  29. 'can now start logging into most login forms, with your application
  30. 'Or other examples.
  31. End Sub
So thanks everyone for your time, hope to find an answer
Cheers!
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 48
Reputation: Ken Sharpe is an unknown quantity at this point 
Solved Threads: 2
Ken Sharpe's Avatar
Ken Sharpe Ken Sharpe is offline Offline
Light Poster

Re: Upload file via PHP upload form.

 
0
  #4
Jul 2nd, 2008
You're confusing yourself, that's why you can't find anything on google.

If you have a VB application that needs to upload something to a server, the the vb application needs to connect to the server, and upload it on its own. It has nothing to do with a php web form.

You can have a SEPARATE php web form that can upload images to the same place, but they will never interact -- they are two different programs doing basically the same thing.

So what you're looking for is kind a mini FTP client in VB. Google that instead.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 3
Reputation: dab is an unknown quantity at this point 
Solved Threads: 0
dab dab is offline Offline
Newbie Poster

Re: Upload file via PHP upload form.

 
0
  #5
Jul 2nd, 2008
Thing is, I don't want to use FTP to connect, or, I'd rather not since I already have all the file restriction things I need. I was hoping I could connect to it with VB and simulate a browser uploading to it. :/
Last edited by dab; Jul 2nd, 2008 at 1:33 pm. Reason: Grammer -.-"
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 1
Reputation: nos_nos is an unknown quantity at this point 
Solved Threads: 0
nos_nos nos_nos is offline Offline
Newbie Poster

Re: Upload file via PHP upload form.

 
0
  #6
Jul 12th, 2009
some variables shown as not decleared
ineed solution quickly please
Last edited by nos_nos; Jul 12th, 2009 at 5:05 am.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 2758 | Replies: 5
Thread Tools Search this Thread



Tag cloud for VB.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC