Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

thread184-1791567 Hi Sir Marco,

Status
Not open for further replies.

vie3548

Programmer
Jul 12, 2021
28
AE
thread184-1791567

Hi Sir Marco,

sorry i am new here.

i tried your code in uploading file via http url but i am unable to make it work.
status returns 200 but no file was uploaded. Did i miss something. pls help

#DEFINE crlf CHR(13)+CHR(10)

strFile="C:\Downloads\RSL6952.PDF"
boundary='--'+STRTRAN(SYS(2015),'_','')
content=FILETOSTR(strFile)
contentname="file1"
strFn=JUSTFNAME(strFile)
API_URL="
cPayload=m.boundary+crlf
cPayload=cPayload+'Content-Disposition: form-data; name="'+m.contentname+'"; filename="'+strFn+'"'+crlf+crlf
cPayload=cPayload+m.content+crlf
cPayload=cPayload+m.boundary+crlf
qPayload=CREATEBINARY(m.cPayload)

oHTTP=CreateObject("MSXML2.ServerXMLHTTP.6.0")
oHTTP.Open("POST",API_URL, .f.)
oHTTP.setRequestHeader("content-type","multipart/form-data; boundary="+SUBSTR(m.boundary,3))
oHTTP.Send(m.qPayLoad)
 
Hello.. hard to tell without viewing the http
traffic and full server response...

Did you check message body? - maybe it has a more detailed message;
also make sure to specify a full qualified address, including http/https ( )

And first of all, make sure the end point works as expected using a simple html upload page!











Marco Plaza
@nfoxProject
 
hi sir,

this is the full address :
this is located in public_html folder

i did try to upload file using the FTP class on different folder (not in public_html)
with host,username,password and its working fine.

i need the file to be uploaded in public_html.
 
You can't upload to a folder, you have to upload to a server side CGI or other script accepting the file upload. Files are always uploaded to server temp folders. If files could be uploaded to a direct URL like it's a folder and you'd not need permissions the internet would be broken.

If FTP works for you, then just find out where to specify the initial target directory you connect to or send a CD command via FTP command (it won't help to CD on the VFP client side), so in general how to send FTP commands after your code stablishes the FTP Server connection and before it uploads files.



Chriss
 
Ok .. that routine was for multipart form data.. !

Regarding the ftp uploads, the site admin is the one who
sets the root folder for the ftp user you are using.






Marco Plaza
@nfoxProject
 
You typically can CD into subfolders, as the root directory set for the TP connection obviously is outside of the public_html web root, you should be able to CD to it.

Chriss
 
hi sir..

got it worked.. its more of login account issue.
thank you for your time
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top