Search code examples
phpfileuploading

PHP move_uploaded_file won't work - is_writable and is_dir = true


I am having trouble uploading file on server.

My code:

$path = "produkty/$kategorie/$last_id/";
if(!is_dir($path)){
  mkdir($path, 0777, true);
}
if (is_dir($path) && is_writable($path)) { echo "ok"; }

And it returned ok.

The upload code looks like this:

move_uploaded_file($_FILES["uvodniobr"]["tmp_name"], $path."uvodniobr.".$ext)

If I echo out:

echo $path."uvodniobr.".$ext;

It will return this: produkty/kategorie/35/uvodniobr.png

Things like checking file size, extension works fine, it just won't upload. Do you know what could be wrong with my code? Thank you

SOLVED EDIT: I was trying to upload file over 2MB without changing php.ini in xampp/php/php.ini upload_max_filesize=2M. Thank you for your answers.


Solution

  • It was my fault, I forgot to change upload_max_filesize=2M to upload_max_filesize=16M in xampp/php/php.ini

    My bad, sorry and thank you for your effort I really appreciate it.