linux curl 上传文件

1. 服务器端程序 up.php

<?php
$uploaddir = '/home/www/uploads/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);

echo '<pre>';
if (move_uploaded_file($_FILES['userfile']['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);

print "</pre>";

?>


另附: 将上述代码上传至 web 服务器下


2. linux下使用 curl上传文件 

# curl --form "userfile=@/Users/username/Downloads/20170502.zip" http://youip/up.php
或使用下面
#curl -F "userfile=@/Users/username/Downloads/20170502.zip" http://youip/up.php

阅读更多

没有更多推荐了,返回首页