file-put-contents

Mutually exclusive flags on file_put_contents?

On the file_put_contents() documentation, it says the following: FILE_APPEND: Mutually exclusive with LOCK_EX since appends are atomic and thus there is no reason to lock. LOCK_EX: Mutually exclusive with FILE_APPEND. Yet, a couple of lines bellow I see the following code: <?php $file = 'people.txt'; // The new person t...

Help with uploading images to EC2 instance (Flash -> PHP)

I have developed an image uploading application that uses Flash to load an image, resize the image and send the bytearray of the image data to a PHP file that outputs the resized file using the following code - $default_path = '/uploads/temp/'; $filename = $_GET["filename"]; $destination = $default_path . $filename; if(file_put_contents...

What user is PHP on my CentOS linux box? root?

Hi I am trying to troubleshoot why I cannot get files to upload to my CentOS machine running on EC2 and think it may be a permissions problem (as I have gleamed from previous questions). How do I check what privileges my PHP installation has for writing files. The directory that I want to write files to has been created in the same folde...

file_get_contents and file_put_contents with large files

Hi there! I'm trying to get file contents, replace some parts of it using regular expressions and preg_replace and save it to another file: $content = file_get_contents('file.txt', true); $content_replaced = preg_replace('/\[\/m\]{1}\s+(\{\{.*\}\})\s+[\x{4e00}-\x{9fa5}]+/u', 'replaced text', $contents); if ($content_replaced) { fi...

php file_put_contents() to a specific id on a page

I'm using file_put_contents() to post text from a text field. I want to post the data to a specific part of the page. file_put_contents('filename.php /* #fooid */', $formData, FILE_APPEND); Is there a way to add an id to post to? Thanks in advance. ...

file_put_contents, file_append and line breaks

I'm writing a PHP script that adds numbers into a text file. I want to have one number on every line, like this: 1 5 8 12 If I use file_put_contents($filename, $commentnumber, FILE_APPEND), the result looks like: 15812 If I add a line break like file_put_contents($filename, $commentnumber . "\n", FILE_APPEND), spaces are added afte...

Simplest way of outputting debug content into file

I've got an applicaiton with various php scripts. I want to get an idea of how much time it takes for the execution to move from one point to another (there are many such points). I was looking for a simple php line that I can insert without modification, at different spots in my code and get an output file (NOT generated html) which sh...