On my local development I use the code shown below, which works perfect,
but when I uploaded the site to my shared hosting everything worked fine except my file upl
Chances are your account's root is /data/sites/web/christophvhbe
, and that getRealPath
is entirely accurate (what you see in FTP is likely chrooted). As a result, your $imagePath
is actually the problem.
$imagePath = '/data/sites/web/christophvhbe/images/producten/'. $fileName;
Or, better yet, use Laravel's base_path
and/or public_path
helpers so if you ever change hosting it keeps working if the paths change:
$imagePath = public_path() . '/images/producten/' . $fileName;
If you consult your error logs, I'll bet you find permissions errors trying to create a file in the server's /images
directory, which on shared hosting you definitely won't be able to create or access.
Simply use this
$_SERVER['DOCUMENT_ROOT']."/path/to/directory"