lundi 26 octobre 2015

Laravel 5 issues on shared hosting with pathinfo() and unwritable directory

I managed to get my laravel app to work on shared hosting.

Following this tutorial, I moved the app files into a /reddit/ directory outside /public_html/ and the files inside /public/ into /public_html/

All works well until I try submitting a post, then I get this error

Can't write image data to path (/images/Q4vQitDu.)

This is the chunk of code it is referring to

$orig = pathinfo($info->image, PATHINFO_EXTENSION);
$extension = substr($orig, 0, strpos($orig, '?'));

$newName = '/images/' . str_random(8) . ".{$extension}";

if (File::exists($newName)) {
    $imageToken = substr(sha1(mt_rand()), 0, 5);
    $newName = '/images/' . str_random(8) . '-' . $imageToken . ".{$extension}";
}

$image = Image::make($info->image)->fit(70, 70)->save($newName);
$embed_data = ['text' => $info->description, 'image' => basename($newName)];

As you can see, it is generating the image name with the dot but not the {$extension} - I have no idea why as it is working locally.

It also says the /images/ is unwritable, but it is. It exists in /public_html/images/ and permissions are set to 777

This is index.php in /public_html/

require __DIR__.'/../reddit/bootstrap/autoload.php';

$app = require_once __DIR__.'/../reddit/bootstrap/app.php';

It is loading files from /reddit/ dir outside /public_html/

I am on PHP 5.5 and these are the loaded modules

enter image description here



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire