PHP Cannot create directory

Source: Internet
Author: User
Public function upload () {$path = "/uploads/news/". Date ("Ymd"), if (!is_dir ($path)) {$res =mkdir ($path, 0777,true); if ($ RES) {echo "directory $path created successfully"; exit;} Else{echo "Directory $path creation failed"; exit;}} echo "here"; exit;


I try to create a directory, but I don't know why I can't always create it, and I always jump right here.


Reply to discussion (solution)

Success or failure always prompts a bar.

Success or failure always prompts a bar.



is if there's no jumping in there, jump right here, don't know what's going on.

It may be that your upload method is not executed at all, check it yourself.

It may be that your upload method is not executed at all, check it yourself.



Yes, upload went in, if the industry executed, but it is not jumping in if inside wonder!

$path = "/uploads/news/". Date ("Ymd"); Remove the front/

$path = "/uploads/news/". Date ("Ymd");
You've built this directory in the root of the server.
The directory already exists, so there is no statement block to execute if.

$path = "/uploads/news/". Date ("Ymd"); Remove the front/




What does it mean to remove the front/whole one? What do I say if I want to represent the Uploads folder in the root directory of this project on the server?

$path = "/uploads/news/". Date ("Ymd");
You've built this directory in the root of the server.
The directory already exists, so there is no statement block to execute if.



Look, it is true that this folder exists, but it is in the Uploads folder of the direct D drive, but I want to make it in the project root directory under the Uploads folder how to do?

$path = $_server[' Document_root '). " /uploads/news/". Date ("YMD")

$path = $_server[' Document_root '). " /uploads/news/". Date ("YMD")



Can you write this on the server as well? I don't know why the catalog echo came out right, but I can't show the picture.
Show such not allowed to load local resource:file:///d:/wamp/apps/p1weixin/uploads/news/20160129/1454032603836.jpg


$path = $_server[' Document_root '). " /uploads/news/". Date ("YMD")



Can you write this on the server as well? I don't know why the catalog echo came out right, but I can't show the picture.
Show such not allowed to load local resource:file:///d:/wamp/apps/p1weixin/uploads/news/20160129/1454032603836.jpg


Your code is a format like this, and it's normal for this to happen.

Writing a file, the problem is either a permissions issue or a path problem. By putting out the wrong information, you can basically find out what the problem is.

  • 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.