Click here to Skip to main content
15,886,422 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am new to PHP but have experience in .net. I need to know a way to save images uploaded to a PHP page in a subdirectory of that page and return its path. I have checked and not found a way to give permission to an existing subdirectory in PHP. I am using wamp for development.

passed subdirectory in file_put_contents with the image file name.
got full path and appended the subdirectory.
$ImagePath = __DIR__.'/driverimages/'.$ImageName ;
file_put_contents($ImagePath, base64_decode($data->profilepic));
Although I haven't included any code here I have tried the above-mentioned steps. I know that if I create a directory from a PHP script with 0774 permission I can write to it. But I need to write to an existing subdirectory and return the image path so that it can be used in the front end to show the image.

I need to be able to write to a subdirectory from the current directory and return the path of the written image file.

What I have tried:

1. passed subdirectory in file_put_contents with the image file name.
2. got full path and appended the subdirectory.

$ImagePath = __DIR__.'/driverimages/'.$ImageName ;
file_put_contents($ImagePath, base64_decode($data->profilepic));


I know that if I create a directory from a PHP script with 0774 permission I can write to it. But I need to write to an existing subdirectory and return the image path so that it can be used in the front end to show the image.

I need to be able to write to a subdirectory from the current directory and return the path of the written image file.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900