简体   繁体   English

使用CURL上传文件

[英]File upload using CURL

i have successfully uploaded a file using CURL. 我已经使用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. 我可以检查文件是否存在。如何获取文件内容。

我只是正常上传文件,如果上传的文件没有正常移动,请检查文件名$_FILES["filecontents"]["name"]存在于您的上传目录中将上传的文件保存到一个临时位置,然后打开当前文件进行追加,然后将内容追加到新上传的文件中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM