无法用php创建文件夹

时间:2014-03-21 09:46:28

标签: php mkdir

我使用了php.net的手册,但我无法让它工作。看不出我做错了什么。我尝试做

时收到此错误消息
Warning: ftp_mkdir(): Can't create directory: No such file or directory in /home/user/public_html/management/test.php on line 11
There was a problem while creating /home/user/public_html/images/screenshots/wiiu/alien_isolation/ 

下面是我使用的代码...

        <?php

        $ftp_user_name = "user";
        $ftp_user_pass = "password";
        $ftp_server = "www.site.com";
        $gamename = "alien_isolation";
        $path = "/home/user/public_html/images/screenshots/wiiu/" . $gamename . "/";
        $conn_id = ftp_connect($ftp_server);
        $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

        if (ftp_mkdir($conn_id, $path)) {
         echo "successfully created $path\n";
        } else {
         echo "There was a problem while creating $path\n";
        } 

        ftp_close($conn_id); 

        ?>

编辑:我的php处理程序设置为DSO,现在可以正常工作

3 个答案:

答案 0 :(得分:0)

您确定路径

/home/user/public_html/images/screenshots/wiiu/

存在?

答案 1 :(得分:0)

将php处理程序设置为DSO并且它可以正常工作

答案 2 :(得分:0)

**Use this** 

<?php
        $ftp_user_name = "user";
        $ftp_user_pass = "password";
        $ftp_server = "www.site.com";
        $gamename = "alien_isolation";
        $path = "/home/user/public_html/images/screenshots/wiiu/";
        $conn_id = ftp_connect($ftp_server);
        $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
        @ftp_chdir($conn_id, $path);
        if (ftp_mkdir($conn_id, $gamename)) {
         echo "successfully created $path\n";
        } else {
         echo "There was a problem while creating $path\n";
        } 

        ftp_close($conn_id); 

        ?>