0

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.\n";
} else {
    echo "Possible file upload attack!\n";
}
echo 'Here is some more debugging info:';
print_r($_FILES);
echo "\n<hr />\n";
print_r($_POST);
print "</pr" . "e>\n";

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.

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.