John Davidson

Sending file to WebDav server using PHP curl

0 comments
Message:


I am trying to send file to the webDav server using curl. My code is working fine but the problem i am facing is curl -T is deleting all the existing file in network. Is there any other flag which can only send one file and donot touch other files in a network.


exec('curl -T "' . $src . $file . '" ' . $full_url . str_replace(' ', '', $upDir) . str_replace(' ', '', $file));


Thanks in advance



My Answer:
You can use the -N flag in curl to only upload the file if it is newer than the one on the server. This way, it will not delete any existing files on the server. Here is an example of how you can modify your code to include the -N flag:

php
exec('curl -T "' . $src . $file . '" -N ' . $full_url . str_replace(' ', '', $upDir) . str_replace(' ', '', $file));


By adding the -N flag, curl will only upload the file if it is newer than the one on the server, and will not delete any existing files.

Rate this post

5 of 5 based on 1093 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us