【问题标题】:HOSTINGER FILE_PUT_CONTENTS HTML2CANVAS : cannot upload the screenshot, but it says that it's not empty [closed]HOSTINGER FILE_PUT_CONTENTS HTML2CANVAS:无法上传屏幕截图,但它说它不是空的[关闭]
【发布时间】:2022-01-20 17:09:13
【问题描述】:

我已经尝试验证画布/屏幕截图是否有效,并且它说有效。我想问题是它没有上传到目录。

我也已经尝试在主机的 Cpanel 中启用 fileUpload 选项。

我也尝试过更改目录,但它仍然不起作用,但它在我的本地主机中运行良好。

if($_POST['image'] != null){
    
    $image = $_POST['image'];
    $picpath = $_POST['picpath']; 

    $image_parts = explode(";base64,", $image);

    $image_base64 = base64_decode($image_parts[1]);
    
    $fileLocation = "./public_html/SBAdmin2/includes/customuploads/".$picpath;
    file_put_contents($fileLocation, $image_base64);


}

【问题讨论】:

    标签: php hosting web-hosting html2canvas file-put-contents


    【解决方案1】:

    尝试类似:

        // ...
    
        $fileLocation = __DIR__ . '/public_html/SBAdmin2/includes/customuploads/' . $picpath;
        file_put_contents($fileLocation, $image_base64);
    }
    

    注意./”指的是当前目录,这可能不是您所期望的,在服务器上它可能指的是另一个目录。

    【讨论】:

    • 谢谢,但这没有用。
    猜你喜欢
    • 2012-03-04
    • 1970-01-01
    • 2022-01-26
    • 1970-01-01
    • 1970-01-01
    • 2018-01-13
    • 2013-01-26
    • 1970-01-01
    • 2022-01-20
    相关资源
    最近更新 更多