Bartłomiej Semańczyk Bartłomiej Semańczyk - 7 months ago 15
PHP Question

"Server error. Upload directory isn't writable."

I use

FineUpload
script to upload images on server. This is the code I use from 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);


I have created a
gallery
directory in
public_html
directory, but still gets the error:


{"error":"Server error. Upload directory isn't writable."}

Answer

Your upload directory must be a local folder relative to your current dir and not a web url. Try getcwd() to know which folder you are in and then use a relative path to your gallery folder.