Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Http File Upload (post)
kvarnerexpress
post Dec 13 2005, 01:10 PM
Post #1


Super Member
*********

Group: Members
Posts: 407
Joined: 13-December 04
Member No.: 2,696



Does anyone know how to upload a file and form data
to a server?

What i want to do is allow a user to upload a file and form data
to my php script so i can process it. So of course FTP would be
no good.

I can do this with the XMLHTTP control but it does not thread and
it pretty lame. Surely you can do it with winsock or Inet

Any ideas?

Source code would be greatly appreciated.
Go to the top of the page
 
+Quote Post
Inspiron
post Dec 13 2005, 01:20 PM
Post #2


Trap Grand Marshal Member
***********

Group: Members
Posts: 1,205
Joined: 25-March 05
Member No.: 4,883



I'm not sure if this is what you are looking for..
Check it out...
http://www.vb-helper.com/howto_upload_files.html

Otherwise use the FTP protocol method...
http://www.vb-helper.com/howto_ftp.html
Go to the top of the page
 
+Quote Post
sinmin
post Feb 13 2006, 10:58 AM
Post #3


Newbie [Level 2]
**

Group: Members
Posts: 29
Joined: 4-February 06
Member No.: 18,197



There are have FTP to be transfer file. I never been hear that using http to trasmit file le...
Go to the top of the page
 
+Quote Post
masterio
post Sep 5 2006, 12:40 AM
Post #4


Member [Level 1]
****

Group: Members
Posts: 50
Joined: 25-August 06
Member No.: 28,897



Hi kvarnerexpress,

I've same problem with you, and after googling for days i didnt found what i want. but the basic for upload file is by sending "Content-Type: multipart/form-data" header. I used INET(Mic. Internet Transfer Control SP4) control for this. I've named this control INETPOST.

assuming the field name is "myfile" and the button name is "upload" for the upload form

CODE
' create sub for making upload post
private sub upload_file()
  dim strPOST as string, Header as string Boundary as string, uagent as string
  dim Idboundary as string   ' id boundary for the site, it may different
  
  uagent = "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7"
  INETPOST.host = "www.somesite.com"
  Idboundary = "9876543210123"    ' you can generate this number
  Boundary = String(27, "-") & Idboundary     ' mutipart post need "-" sign
  
  Header = uagent & vbCrLf & "Content-Type: multipart/form-data; " & "boundary=" & Boundary
  
  strPOST = "--" & Boundary & vbCrLf & _
  "Content-Disposition: form-data; name=""myfile""" & vbCrLf & vbCrLf & _
  """ & EncodeBin & """ & vbCrLf & _
"--" & Boundary & vbCrLf & _
"Content-Disposition: form-data; name=""upload""" & vbCrLf & vbCrLf & _
"Upload File" & vbCrLf & _
"--" & Boundary & "--" & vbCrLf

INETPOST.Execute "http://www.somesite.com/upload.php", "POST", strPOST, Header

  ' Wait untill it finished
  Do Until BekasNET.StillExecuting = False: DoEvents: Loop
end sub

' function to encode binary file
Function EncodeBin(SourceFile As String)
Dim buf As String, File1 As Integer

File1 = FreeFile

Open SourceFile For Binary Access Read As #File1
  ' make buffer to storing file's content
  buf = Space(LOF(File1))
  Get #File1, , buf
Close #File1

EncodeBin = buf

End Function


Hope's help!! biggrin.gif

This post has been edited by masterio: Sep 5 2006, 12:43 AM
Go to the top of the page
 
+Quote Post
adiaz01
post Oct 14 2007, 04:02 PM
Post #5


Newbie
*

Group: Members
Posts: 7
Joined: 30-September 07
Member No.: 50,874



Q: Does anyone know how to upload a file and form data
to a server?

Assumptions that I made by reading your question and comments.
You have a server with PHP as a web script and you want to save a file from you users desktop/volume/share to the http server using an html form.

if this is correct you have to go to http://www.tizag.com/phpT/fileupload.php
I think this is what you looking for you can save information from a form to a database and upload a file to a server using PHP.

Hope this help!!

Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics


 



- Lo-Fi Version Time is now: 26th July 2008 - 03:18 PM