“服务器错误。上传目录不可写。”

时间:2016-05-02 12:09:19

标签: php

我使用FineUpload脚本在服务器上上传图片。这是我在 localhost

中使用的代码
<?php
require 'FineUpload.php';

$uploadDir = 'http://www.naukaplywaniakrakow.pl/gallery/';
$allowed   = explode(',', 'pdf');
$sizeLimit = 5000 * 1024;

$fineUpload = new FineUpload($allowed, $sizeLimit);
$response   = $fineUpload->handleUpload($uploadDir);

if (@$response['success']) {
    $uploadName = $fineUpload->getUploadName();

    list($width, $height) = getimagesize($uploadDir . $uploadName);

    $response['fileName'] = $uploadName;
}

echo json_encode($response);

我在gallery目录中创建了一个public_html目录,但仍然收到错误:

  

{“error”:“服务器错误。上传目录不可写。”}

2 个答案:

答案 0 :(得分:2)

您的上传目录必须是相对于您当前目录的本地文件夹,而不是网址。 请尝试getcwd()了解您所在的文件夹,然后使用gallery文件夹的相对路径。

答案 1 :(得分:0)

立即尝试。

<?php

require 'FineUpload.php';

$uploadDir = 'http://www.naukaplywaniakrakow.pl/gallery/';
$allowed   = explode(',', 'pdf');
$sizeLimit = 5000 * 1024;


$fineUpload = new FineUpload($allowed, $sizeLimit);
chmod($fineUpload,0777);
$response   = $fineUpload->handleUpload($uploadDir);

if (@$response['success']) {
    $uploadName = $fineUpload->getUploadName();

    list($width, $height) = getimagesize($uploadDir . $uploadName);

    $response['fileName'] = $uploadName;
}

echo json_encode($response);


?>