我使用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”:“服务器错误。上传目录不可写。”}
答案 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);
?>