I am trying to upload a file to a remote server using curl and post method
here is what I have:
$file = $dir."".$dbfile[0];
$this->invoiceno = $dbfile[1];
$uploadpath = "http://www.website.com;
$postvar = array ();
$postvar['cboFileType'] = "837";
$postvar['txtDesc'] = "Invoice No. ".$this->invoiceno;
$postvar['btnSave'] = "Upload File";
$postvar['FILE1'] = "@$file";
$postvar['UPLOADING'] = "true";
$this->postvariables =
"txtUserName=".$this->user."&txtPassword=".$this->password."&btnLogin=Log
In";
// login first
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->login_post);
curl_setopt($ch, CURLOPT_USERAGENT, $this->agent);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $this->postvariables);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_REFERER, $this->reffer);
curl_setopt($ch, CURLOPT_COOKIEFILE, $this->cookie_file_path);
curl_setopt($ch, CURLOPT_COOKIEJAR, $this->cookie_file_path);
$results = curl_exec ($ch);
// upload file
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$postvar);
curl_setopt ( $ch, CURLOPT_URL, $uploadpath);
$uploaded = curl_exec ( $ch );
echo $uploaded;
I think my problem is that the file I need to upload is not in the same
directory on the server as this script. I am setting $file =
/var/www/include/upload/test.txt and this is what seems to be causing the
problem. I can find very little information on this topic on google so I
need your help. Do I need to copy the file to the same directory that the
script is in or is there something else I am missing? If I just set $file =
test.txt how would the server know where to find the file?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php