Laravel 5在使用pathinfo()和不可写目录的共享主机上发布了问题

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

UPDATE

I fixed the permission issue by changing the /images/ url to the full server url /home/maghnatis/public_html/images/

But images are still being saved without their extension.

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

Fixed.

instead of /images/

I used the full server path /home/maghnatis/public_html/images/

And I checked for extension name before sending it to the database

$orig = pathinfo($info->image, PATHINFO_EXTENSION);
$qmark = str_contains($orig, '?');
if($qmark == false) {
    $extension = $orig;
} else {
    $extension = substr($orig, 0, strpos($orig, '?'));
}