Expand my Community achievements bar.

Submit XML - FTP Server wants username and password

Avatar

Former Community Member
I am new to Livecycle and very excited about the product.



I would like the Acrobat 8 users of my PDF form (that was created in Livecycle 8.2) to submit their XML data to my ftp server when they hit my submit button.



I have create a submit button and entered into the object URL:ftp://xxx.com/home/wildedge/public_html/docs/

Submit as: XML Data (XML)

Data Encoding: UTF-8



My ftp server wants a username and password to be entered before it will allow a file transfer. How do I submit my username and password with this submit button?
5 Replies

Avatar

Former Community Member
I found this in the archives, but I don't know what to do with it.



Grant Rauscher - 12:10pm Jul 25, 07 PST (#5 of 6)



Would the following script work to upload the file?



private static void Upload(string ftpServer, string userName, string password,

string filename)

{

using (System.Net.WebClient client = new System.Net.WebClient())

{

client.Credentials = new System.Net.NetworkCredential(userName, password);

client.UploadFile(ftpServer + "/" + new FileInfo(filename).Name,

"STOR", filename);

}

}



Upload("ftp://ftpserver.com", "TheUserName", "ThePassword", @"C:\file.txt");

Avatar

Level 7
You don't submit to an FTP server. You submit to a web script (ASP,

CGI, PHP, that sort of thing) running on an http server. Submitting is

a process of handing the form fields to a program on another computer,

it isn't a quick and handy way to upload.



Aandi Inston

Avatar

Former Community Member
Thanks Aandi.



Can anyone post a sample PHP/MySQL script that successfully accepts an XML document from a HTTP Submit statement embeded in an Acrobat PDF (Created with LiveCycle Designer ES 8.2)?

Avatar

Former Community Member
Here is the PHP Script I ended up using on this project to make it all work, I called XMLupload.php. Just in case someone has the same questions I had.
<br />
<br /><?<br /?>
require_once("configuration.php");
<br /> $conf=new JConfig();
<br /> $con=mysql_connect($conf-&gt;host,$conf-&gt;user,$conf-&gt;password);
<br /> mysql_select_db('wilder_joomla',$con);
<br />
<br /> define('ADMIN_ROOT_DIR',dirname(__FILE__));
<br /> $xml_uploaddir = ADMIN_ROOT_DIR."/administrator/xml/";
<br /> $pdf_uploaddir = ADMIN_ROOT_DIR."/administrator/pdf/";
<br />
<br /> function random($length)
<br /> {
<br /> $hash =date('YmdHis',time()+8*3600)."_";
<br /> $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz';
<br /> $max = strlen($chars) - 1;
<br /> mt_srand((double)microtime() * 1000000);
<br /> for($i = 0; $i &lt; $length; $i++)
<br /> {
<br /> $hash .= $chars[mt_rand(0, $max)];
<br /> }
<br /> return $hash;
<br /> }
<br /> function get24hTime($time){
<br /> if(strpos($time, "am")){
<br /> $time = trim(str_replace("am","",$time));
<br /> $temp = split(":",$time);
<br /> return substr("0".$temp[0],strlen($temp[0])-1).":".$temp[1];
<br /> }else if(strpos($time, "pm")){
<br /> $time = trim(str_replace("pm","",$time));
<br /> if(substr($time,0,2)=="12") return $time;
<br /> return strval(intval(substr($time,0,strpos($time,':')))+12).substr($time,strpos($time,':'));
<br /> }
<br /> }
<br />
<br /> $file_path = $xml_uploaddir.random(10).".xml";
<br /> $temp = split("/",$file_path);
<br /> $xml_path = $temp[count($temp)-2]."/".$temp[count($temp)-1];
<br />
<br /> $body = file_get_contents("php://input");
<br /> $fp=fopen($file_path,"w");
<br /> fwrite($fp,$body);
<br /> fclose($fp);
<br />
<br /> $xml=simplexml_load_file($file_path);
<br /> $nodes=$xml-&gt;xpath("/form1/P1");
<br /> $xml_groupname=$nodes[0]-&gt;group_name[0];
<br /> $xml_groupname=addslashes($xml_groupname);
<br /> $xml_checkin_date=$xml-&gt;DateofArrival;
<br /> $xml_checkin_time=get24hTime($xml-&gt;ArrivalHour);
<br /> $xml_checkin_date.=" ".$xml_checkin_time.":00";
<br /> $xml_contact_person=$nodes[0]-&gt;contact_name[0];
<br /> $xml_contact_email=$nodes[0]-&gt;contact_email[0];
<br />
<br /> /*
<br /> print_r("FilePath: $file_path
<br />");
<br /> print_r("GroupName: $xml_groupname
<br />");
<br /> print_r("checkin_date: $xml_checkin_date
<br />");
<br /> print_r("contact_person: $xml_contact_person
<br />");
<br /> print_r("contact_email: $xml_contact_email
<br />");
<br /> */
<br />
<br /> $sql = "insert into jos_xml_files (status,file_path,pdf_path,group_name,checkin_date,contact_person,userid,add_time,email) values (0,'$xml_path','','$xml_groupname','$xml_checkin_date','$xml_contact_person',0,now(),'$xml_contact_email')";
<br /> mysql_query($sql);
<br /> $message ='
<ul class="noindent">
<li>XML file is uploaded successfully.</li>
<li style="list-style: none">';
<br /> mysql_close($con);
<br />?&gt;
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br /></li>
</ul>
<div id="showmsgmain">
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<table width="57%" align="center" style="border:1px solid #e5e5e5">
<tr>
<td height="25" bgcolor="#E5E5E5">&#160;Information suggested!</td>
</tr>
<tr>
<td height="122">
<br />
<div style="margin-left: 2em; color:#0066CC;">
<br /> <?php echo $message;?>
<br /></div>
<br /></td>
</tr>
</table>
<br /></div>
<br />
<br />

Avatar

Former Community Member
You can try the following syntax to put user credential and ftp URL together



ftp://guest-user:MyPassword@myFTP.com/myFolder





Where



Host: myFTP.com

Username: guest-user

Password: MyPassword

Directory: myFolder