Did a fresh install of spark, everything seems to be working fine however when i tried to upload a profile image the page refreshed and the profile image is not being found. The link is pointing to
Spark documentation: Linking The Storage Directory
Once Spark is installed, you should link the public/storage directory to your storage/app/public directory. Otherwise, user profile photos stored on the local disk will not be available:
Also tried other variants of the above from the root of the project.
*edit - dropping a file manually into the /public/storage directory replicates it back to the /storage/app/public directory as expected. So Im thinking this might be a spark bug?
is your app actually running on the "localhost" domain? It stores the domain as part of the image path in the db so unless you set APP_URL correctly in your .env it will use the default of "http://localhost" which may not be correct.
Also, when doing the linking, if you are in a VM like homestead you need to run the artisan command or manual linking from within the VM, not your local filesystem.
Folks, you would be best served by thoroughly reading the laravel docs on storage. If your permissions are correct and your APP_URL is correct, then you should have to do nothing more than run php artisan storage:link without any special variants. Once these items are posted, they are stored locally in a very Laravel specific manner and have to be accessed in a Laravel specific manner...all of this is explained in the docs. Do yourself a favor and read the Laravel docs. Personally, I have not encountered any problems using storage and it should work perfectly for you as well. And, that includes using it in Spark.
@Daaf Yes Said is fixing it. That commit you linked to which was trying to delete the previously uploaded image (because they weren't by default) accidentally deleted the newly uploaded image instead. So it's deleting the image as soon as it gets saved to disk.
Update the handle method in Vendor > Laravel > Spark > Interactions > Settings > Profile > UpdateProfilePhoto as:
public function handle($user, array $data)
{
$file = $data['photo'];
$path = $file->hashName('public/profiles');
// We will store the profile photos on the "public" disk, which is a convention
// for where to place assets we want to be publicly accessible. Then, we can
// grab the URL for the image to store with this user in the database row.
$disk = Storage::disk('local');
$disk->put($path, $this->formatImage($file));
if (preg_match('/profiles\/(.*)$/', $user->photo_url, $matches)) {
$disk->delete('public/profiles/' . $matches[1]);
}
$user->forceFill([
'photo_url' => $disk->url($path),
])->save();
}
@Korona123 You need to register your github with Spark via the spark website when logged in in order to access the private spark repo, but this was fixed many versions ago.
I've hard this same issue with Laravel Spark 6.0 today. To fix it, set you.envAPP_URL to a proper URL matching your site. Finally go into your database and change the photo_url url to match your domain in the users table.