Post-how do I upload a file to the established directory with the Curl command? Backstage with PHP program to receive, Apache httpd do server

Source: Internet
Author: User
Keywords Php apache curl post
Tags tmp folder
Use the Curl command to upload files to the server, but only to the/tmp folder, what is this for?
Linux command Line input:

curl -F upload=@/root/yifei.txt http://server_ip/upload.php

Put the file in the server-side/var/www/html/upload.php


  
   

Here can only make the TMP directory, if the development of other directories will upload failed, so can only be uploaded to the/tmp folder inside, how can I upload to the specified directory?

Reference: Http://www.aslibra.com/blog/post/curl_po ...

Reply content:

Use the Curl command to upload files to the server, but only to the/tmp folder, what is this for?
Linux command Line input:

curl -F upload=@/root/yifei.txt http://server_ip/upload.php

Put the file in the server-side/var/www/html/upload.php


  
   

Here can only make the TMP directory, if the development of other directories will upload failed, so can only be uploaded to the/tmp folder inside, how can I upload to the specified directory?

Reference: Http://www.aslibra.com/blog/post/curl_po ...

Move files from the temp directory to the target upload directory

Move_uploaded_file ($file [' Tmp_name '], $filename)

Reference http://php.net/manual/zh/function.move-u ...

The move_uploaded_file() following is what I wrote with the YII framework:

if (!empty($_FILES['avatar']['name'])) {    $file_name = $_FILES['avatar']['name'];    $path = Yii::getAlias('@webroot') . DIRECTORY_SEPARATOR . 'upload' . DIRECTORY_SEPARATOR . $file_name; //图片保存路径    $file = $_FILES["avatar"]["tmp_name"];    move_uploaded_file($file, $path);}

Yii::getAlias('@webroot')Corresponding 'D:/xampp/htdocs/project/web' to the physical path, the Linux server will be different.

You can choose to copy a copy of the past, pay attention to folder permissions issues;
Move_uploaded_file () is also possible, but note whether the folder has write permissions

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.