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
0
votes
1 answer

Base64Decode to file - whats missing?

I have in base64 encoded string in a $_POST field $_POST['nimage'] if I echo it directly as the src value in an img tag, i see the image just fine in browser: echo ""; Now, I'm obviously missing a step, because when I…
DMSJax
  • 1,709
  • 4
  • 22
  • 35
0
votes
3 answers

PHP - file_put_contents Save file in folder

Trying to save an attachment from email into my server, the script I have so far works fine however, it saves the file in my wp root folder. foreach ($attachments as $key => $attachment) { $name = $attachment['name']; $contents =…
SNos
  • 3,430
  • 5
  • 42
  • 92
0
votes
0 answers

Warning: file_put_contents(localhost/video/): failed to open stream: No such file or directory in C:\wamp\www\Yoyo\download.php

I'm implmenting a YouTube downloader which stores video onto a server from here. I've modified the code for the downloading YouTube video on a server rather than a computer. Here is my code for download.php: include_once('config.php'); // Check…
Leslie Ryan
  • 29
  • 1
  • 2
0
votes
1 answer

Php writing string to file in ../src

So I'm trying to get my php script append a text to log.txt, log.txt is placed in src/log.txt and the php script in web/script.php (they have other names but well...) So I've tried: $logfile1 = fopen('log.txt', 'a', [$use_include_path =…
Svante
  • 45
  • 1
  • 11
0
votes
1 answer

Getting files from webpage and save with file_put_contents

I tried making a script that could save all files from a webpage with a pattern in name to a server.
fixern256
  • 23
  • 5
0
votes
1 answer

php - read content web page for especial address

I want get content of this Web Page using php functions (e.g file_put_contents, curl_init etc.) but I get ������� as response. Why does that happen? I solved my problem. after get content web page,I using…
hediehloo
  • 1
  • 2
0
votes
0 answers

update a JSON file using PHP/MYSQL - limit size issue

The code below works great until i have around 25000-30000 objects in the Json array stored. Then the file isn't update anymore. Does someone know what could be the issue? foreach ($serials as $key => $serial_list) { foreach ($serial_list as…
llaid
  • 85
  • 1
  • 10
0
votes
2 answers

Edit a PHP file with PHP without duplicate content

So I have been trying to edit a PHP file after it is created and I seem to keep running into problems. Here is my source code. if($pbtype == 'pwall' OR $pbtype == 'cl') { $file = '../postback/pwallpb.php'; $pbac =…
c0d3x1337
  • 47
  • 11
-1
votes
2 answers

php://input and file_get_contents just output the POST data rather than process it

I have the following snippet of code. For the URL QueryString, I am passing in php://input. In the body of the request I am passing in $image_url=$_GET['URL']; $data = file_get_contents($image_url); $new =…
pee2pee
  • 3,619
  • 7
  • 52
  • 133
-1
votes
1 answer

PHP - Incrementing multiple values in a text file with explode

I'm trying to increment a counter inside a text file, that counts HTTP responses from some APIs. This part is handled correctly at the moment. The issue I'm having is that when my text file has more than two values that need to be incremented, only…
-1
votes
2 answers

file_put_contents doesn't give write permissions error

I've been using file_put_contents in order to create txt files inside a specified folder that has write permissions: file_put_contents($dir.$file.'.txt', $content); Editing my code, I made a mistake: I wrote $dir = '/../../xxx/yyy/'; (that actually…
AbsoluteBeginner
  • 2,160
  • 3
  • 11
  • 21
-1
votes
1 answer

How to download file Using PHP that has delayed force download?

I am at a situation, where I need to download files from the URL, it is easy with the direct file URLs like https://somedomain.com/some-path/somefile.exe file_put_contents( $save_file_loc, file_get_contents($url_to_download); But what to do when…
-1
votes
2 answers

How to echo a website page in php that has js file in it?

There is a site that I want to scrape: https://tse.ir/MarketWatch.html I know that I have to use: file_get_contents("https://examplesite.html") to get the html part of site, but how can I find a specific part of site for example like this part in…
TheFaultInOurStars
  • 3,464
  • 1
  • 8
  • 29
-1
votes
2 answers

Php script returning array array?

I have created an php script in order to read data send from an android app to php and save it in file but upon opening the text file i'm getting following statement :- ArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArray instead of data…
-1
votes
1 answer

How can add in data of "file_put_contents" an array and a variable?

i would to use file_put_contents($filename, $data) but i have to add a bidimensional array and a variable: $array= array( array("a","a"), array("b","b") ); $variable= 1; How can i add them in $data ? Is possible to do this by not adding…
Borja
  • 3,359
  • 7
  • 33
  • 66