Image Path Stores With Forward(\) Slash In Db Why ? Help Heeded When I Upload An Image Its Path Stores With Forward () Slash In Db Don't Know Why This Happenz
Here Is Code
$image = Request::file('image');
$destinationPath = 'uploads/';
$name = time().'-'.$image->getClientOriginalName();
$path = Request::file('image')->move($destinationPath, $name);
$user->image_path = $path;
$user->save();
Image Path Saves In Db But In Wrong Way Like This
uploads\1428506792-Hydrangeas.jpg
But why Its Inserted With Forward Slash ? I Need This Path uploads/1428506792-Hydrangeas.jpg
$image = Request::file('image');
$destinationPath = 'uploads/';
$name = time().'-'.$image->getClientOriginalName();
$path = Request::file('image')->move($destinationPath, $name);
$user->image_path = $path;
$user->save();
Formatted your code so it's easier to read.
Hey Ruffles How can i Formatted My Code Here. I Am New Here
Why worry about the direction of the slash? If you are going to end up using it in a src= tag in HTML you will want it to have that forward slash. PHP itself does not much care.
put the code between 3 ` like:
// ```
// code here
// ```
more info at the link near the "Post your Reply" button
@sonu its better you just save the name of the file to the database and its obvious you will know the directory path as you are writign logic so fetch only name of the file and eco out the filepath yourself.
Thanks SachinAgarwal And Ruffles
I am now using str_replace to change forward slash to back and its works now.
Please sign in or create an account to participate in this conversation.