使用CURL上传文件

i have successfully uploaded a file using CURL.

$uploaddir = realpath('./') . '/';
$uploadfile = $uploaddir . basename($_FILES['file_contents']['name']);
echo '<pre>';
if (move_uploaded_file($_FILES['file_contents']['tmp_name'], $uploadfile)) {
    echo "File is valid, and was successfully uploaded.
";
} else {
    echo "Possible file upload attack!
";
}
echo 'Here is some more debugging info:';
print_r($_FILES);
echo "
<hr />
";
print_r($_POST);
print "</pr" . "e>
";

But before uploading I want to check if the file is present and if present append to it. I can check if the file is present or not.How do I get the content of the file uploaded.

I would just upload the file as normal, check to see if the filename $_FILES["filecontents"]["name"] exists in your uploaded directory, if it doesn't move the uploaded file as normal, if it does, move the uploaded file to a temporary location, then open the current file for appending and then append the content to the newly upload file to it.