troubleshooting Question

How to replace files in a remote server using curl????

Avatar of altariamx2003
altariamx2003Flag for Mexico asked on
PHP
4 Comments1 Solution277 ViewsLast Modified:
Hi I would like to know how to replace files in a remote serverver using curl

Right now im using this function to upload file to my remote server using curl
 
$ftpurl = "ftp://".$ftpuser.":".$ftppass."@".$ftppath;
 $fp = fopen($galeria, 'r');
 $ch = curl_init();
 curl_setopt($ch, CURLOPT_URL, $ftpurl.$galeria);
 curl_setopt($ch, CURLOPT_UPLOAD, 1);
 curl_setopt($ch, CURLOPT_INFILE, $fp);
 curl_setopt($ch, CURLOPT_INFILESIZE, filesize($galeria));
 curl_exec($ch);
 $error = curl_errno($ch);
 curl_close ($ch);
 if ($error == 0) 
 { $bandera = true;  } 
 else 
 { $bandera = false; }

That works when the file that Im try to upload doesnt exist on the remote server

How can I use that code to upload files no matter what that file exists on the remote server
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros