PHP move_uploaded_file is Not uploading Images when full web path is given in Unix system

后端 未结 4 927
猫巷女王i
猫巷女王i 2020-12-12 05:09

My Following code is working fine when I set

$target = \"size_images/14_20131216231522_cashew.jpg\";

But Not Working

相关标签:
4条回答
  • 2020-12-12 05:14

    Try using:

    $target = $_SERVER['DOCUMENT_ROOT']."/size_images/14_20131216231522_cashew.jpg";
    

    If you want to upload from subdomain.mydomain.com to mydomain.com simply put the upload script on mydomain.com and then use a relative path.

    0 讨论(0)
  • 2020-12-12 05:22

    You are misunderstanding how move-uploaded-file() works. It is similar to "File Save", namely you have to tell the PHP script a locally-writeable directory and file name where the file goes.

    You mention you're trying to go from "subdomain" to "main domain"... if these two web urls are hosted on the same machine, this will be possible, you will just choose the directory that has the files for the "main domain" site.

    0 讨论(0)
  • 2020-12-12 05:34

    Try this, You need to use only relative path instead of domain path. Domain path doesn't work

    $target = "size_images/14_20131216231522_cashew.jpg";
    move_uploaded_file($_FILES["item_image"]["tmp_name"],$target);
    

    instead of ,

    $target = "http://examples.com/size_images/14_20131216231522_cashew.jpg";
    move_uploaded_file($_FILES["item_image"]["tmp_name"],$target);
    

    Send a file via POST with cURL and PHP Ref: http://blog.derakkilgo.com/2009/06/07/send-a-file-via-post-with-curl-and-php/

    0 讨论(0)
  • 2020-12-12 05:34

    It has to be a relative path.. absolute path would not work.

    Also make sure that you know the difference between "/" and "./" But I would strongly recommend to either use configuration variables(in case of framework) OR constants to store file path.

    Former point to root and later point to current directory..

    0 讨论(0)
提交回复
热议问题