Questions tagged [file-put-contents]

`file_put_contents()` is a PHP function which writes a string to a file.

file_put_contents() is a PHP function, introduced in PHP 5.1.0, which writes a string to a file. It was added as a shortcut and calling this function is identical to calling fopen(), fwrite(), and fclose() successively to write data to a file.

If the file attempting to be written to does not exist, the default behavior of the function is to create the file.

For more information on this function, please see the PHP manual: https://php.net/manual/en/function.file-put-contents.php

245 questions
1
vote
1 answer

How to omit/ignore tags like
when passing PHP content to a YAML file?

I want to 'print' the output of a PHP file into a YAML My original PHP output looks like this: , and goes on for 150 more blocks. As you can see, it has the YAML file structure. I would like to print that output into the YAML file so that those 150…
1
vote
1 answer

downloaded file from file_put_contents is not working

I have stored QR Code image as data in my database and I use this example link to download it: http://example.com/module/index.php?QRCodeFile=1&fileID=1 Now, I am trying to download this picture inside a folder to use it to create a pdf later. My…
Fahad
  • 113
  • 2
  • 15
1
vote
2 answers

Save CSV Export to Server

I have the code below which triggers when a button is pressed in the WordPress admin panel. This opens a csv file called 'ss-stock-export.csv'. How can I save this file to my server in my uploads directory at wp-content/uploads/exports/? I tried to…
1
vote
1 answer

php - create file not working

I have this PHP script that is supposed to create an article when you fill out a form. I go the code from various sources combined but it does not seem to work. The code does not report any errors but when I try to go to…
user8142790
1
vote
0 answers

How to create file from 'blob:http://' url

I have blob:http://unifiedmain.localhost.com/a4580f39-8f9d-4e8c-8e4b-02a6bd2df3df url and i want to create actual file file from this. I've used PHP code : file_put_contents('E:\www\nginx\html\unifinedmainsite\123.mp3',…
Archish
  • 850
  • 8
  • 32
1
vote
1 answer

Writing content stored in variable to csv file

I have a line of data stored in $StripContent, when I echo $Stripcontent it shows , , ,1 ,1415 ,Fietsen ,Omafietsen ,Avalon ,F 101 Oma Export 57cm Zwart , ,57 ,single speed remnaaf ,2017 ,21 ,249.00 ,135.00 ,19.50 ,8 However when I write…
Coenfusing
  • 15
  • 4
1
vote
0 answers

save remote (dynamic generated) PDF to server

I would like to copy a PDF from a URL (API) to our server with PHP. When I call the URL in the browser, the file start to download directly, so this ain't a static PDF/URL. I think that's problem. I've tried different functions with PHP but with no…
Uklo
  • 11
  • 2
1
vote
1 answer

file_put_contents failed to open stream: Permission denied

Basic php and javascript website No errors on Wamp When I put the files on my Lamp server everything works except for this error I get on the top of the page Warning: file_put_contents(donneesDonut.json): failed to open stream: Permission denied…
honeyspoon
  • 1,354
  • 1
  • 11
  • 13
1
vote
2 answers

Parse data from data sent by webhooks

A webhook is sending me some data to the URl I have provided. I am trying to catch the data. This is the code I am using:- if ($this->input->server('REQUEST_METHOD') == 'POST') { file_put_contents('test.txt', file_get_contents('php://input')); …
Saswat
  • 12,320
  • 16
  • 77
  • 156
1
vote
2 answers

How can I validate image saved with file_put_contents()?

I am using file_put_contents($path, $image); to save an image which a user will upload through a plugin (slimimagecropper.com FYI). I'm concerned about XSS. What is the best way to check $image for XSS before saving it with file_put_contents()?
Nadine
  • 777
  • 1
  • 11
  • 24
1
vote
1 answer

Why does my JSON array turn into an object?

I am trying to unset a value from test_bots.json and save it back, but somehow the data format is being changed in the process. test_bots.json contains this JSON array: ["John","Vladimir","Toni","Joshua","Jessica"] My code looks like this: $good =…
MHB2011
  • 453
  • 1
  • 7
  • 22
1
vote
1 answer

file_put_contents error while running the PyroCMS installer

http://pyrocms.com/documentation/pyrocms/v3.1#installation/installing-pyrocms/running-the-installer Getting this error "An exception has been thrown during the rendering of a template ("file_put_contents(app/default/assets/admin/theme.css): failed…
Digvijay
  • 7,836
  • 3
  • 32
  • 53
1
vote
1 answer

which one is more reliable in php ftp_connect vs file_put_content(ftp://)

in my php restful api running on a heroku dyno, since my api accept user to upload files view ($_FILES) -form post- i need to forward the uploaded files to my ftp server to persist them since heroku does not have storage. i googled around to find…
Zalaboza
  • 8,899
  • 16
  • 77
  • 142
1
vote
2 answers

PHP file_get_contents/file_put_contents changing date format of CSV

I am writing a PHP script to automatically download a CSV file. When I manually visit the URL from the web-browser(safari) and download the file and open it in MS Excel, columns A and D (date and time respectively) are formatted as I would expect,…
Russell
  • 63
  • 1
  • 7
1
vote
1 answer

How to put_file_contents with php without user denied error?

I'm trying to replace the contents of a file in a different folder than my php file folder, and I'm getting an error: "Failed to open stream, Permission Denied" I'm using the put_file_contents function to change the file contents. I searched online…
mk117
  • 753
  • 2
  • 13
  • 26