In my C++ program I download images (album art etc.) from over the air radio signals and need to save the images in a public web folder such as /var/www/html to serve later via a web page.
Here's the code to save the image array -
std::string filePath = "/var/www/html/output1.jpg";
std::ofstream ofs(filePath);
ofs.write(image->c_str(), image->size()); // image is JPEG image as string array
ofs.flush();
ofs.close();
Above code won't create file at the specified location, however it will work if the path is just "output1.jpg".
Clearly, my app doesn't have permission to write to /var/www/html. Is there any way to solve this using standard c++ or boost?
Thanks
Aucun commentaire:
Enregistrer un commentaire