is correct to use file_put_contents ?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
aneuryzma
Forum Contributor
Posts: 106
Joined: Sat May 17, 2008 7:03 am

is correct to use file_put_contents ?

Post by aneuryzma »

I want to create a file from my raw data, but I don't want to save it to the filesystem. Rather I want to use it in the next function. Could you help me ?

Code: Select all

file_put_contents('filename.ext', $GLOBALS["HTTP_RAW_POST_DATA"]);
 
$src = $message->attach($img);
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Re: is correct to use file_put_contents ?

Post by infolock »

well, the definition of a file is one that is created on the filesystem.

If you don't want to create a file, use an array
aneuryzma
Forum Contributor
Posts: 106
Joined: Sat May 17, 2008 7:03 am

Re: is correct to use file_put_contents ?

Post by aneuryzma »

Hi,

how can I solve this:

Code: Select all

 
file_put_contents('screenshot.jpg', $GLOBALS["HTTP_RAW_POST_DATA"]);
$img =& new Swift_Message_Image(new Swift_File("screenshot.jpg"));
 

The Swift function wants a file from hard disk, but I would prefer to pass my image without saving it in the filesystem.

thanks
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Re: is correct to use file_put_contents ?

Post by infolock »

use GD library or store the image contents into a string.
Post Reply