MK12
MK12

Reputation: 491

Laravel public_path() return C:\wamp\www\ instead of C:/wamp/www

 $path = (public_path("images/") . $filename);

 echo $path;

C:\wamp\www\jobpost\public\images/Person.PNG //problem occur from this /

I want this path to access my picture

C:\wamp\www\jobpost\public\images\Person.PNG //how i can do this

 (public_path("images\") . $filename); 
 //i add the slash like this error occur

Upvotes: 3

Views: 2469

Answers (1)

hassan
hassan

Reputation: 8288

you are providing linux directory separator , while you are in windows.

you may use the windows separator directly as follows:

$path = (public_path("images\\") . $filename);

or simply to make is safer you should use the DIRECTORY_SEPARATOR pre-defined CONSTANT as follows:

$path = (public_path("images") . DIRECTORY_SEPARATOR . $filename);

update

the issue with that:

(public_path("images\") . $filename);

is that you are escaping the double quotes while you need it to enclose your string parameter.

Upvotes: 2

Related Questions