Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Chrizzmeister's avatar

->getRealPath() is wrong , how do i change it?

On my local development i use the following code, wich works perfect, but when i uploaded the site everything works fine except my file upload. I already determined that the problem is ->getRealPath() , when i dd(); that i get this path: "/data/sites/web/christophvhbe/tmp" wich doenst exist on my hosting. But i found where the temporary images are stored on my server , wich is in the tmp/ located here: http://gyazo.com/e0199718324119109a4ff66321414e12 . How can i change the ->getRealPath() value to the correct value?

$fileName = time() . '-' . $request->file('foto')->getClientOriginalName();
        $product->foto = $fileName;
        $product->save();

        $imagePath = '/images/producten/'. $fileName;

        $image = Image::make($request->file('foto')->getRealPath())->fit(300)-      >save($imagePath);

I'm using the Image/intervention package to upload and store images

0 likes
4 replies
davidfaux's avatar

I think the tmp folder shown in your screenshot is the tmp folder outputted by dd()

Is the '/images/producten/' folder writable?

webstudiopro's avatar

Hello,

I have same problem with ->getRealPath() and a dd() gave me "/home/forge/default/public" on my remote instead of "/tmp/php80yDX4" on my localhost. I'm using Forge with Ubuntu on DigitalOcean. Does anybody have a glue how to configurate the remote server? THX Fret Benny

sameermalikrp's avatar

check and write the answer

$image = Image::make($_FILES['poto']['tmp_name'])->fit(300)->save($imagePath);

Please or to participate in this conversation.