Answers for "php read string from file"

PHP
0

transfer file using file_get_content

$filename = "/path/to/uploaded/file.zip";
$file_contents = file_get_contents($filename);    

$content =  "--".MULTIPART_BOUNDARY."rn".
            "Content-Disposition: form-data; name="".FORM_FIELD.""; filename="".basename($filename).""rn".
            "Content-Type: application/ziprnrn".
            $file_contents."rn";

// add some POST fields to the request too: $_POST['foo'] = 'bar'
$content .= "--".MULTIPART_BOUNDARY."rn".
            "Content-Disposition: form-data; name="foo"rnrn".
            "barrn";

// signal end of request (note the trailing "--")
$content .= "--".MULTIPART_BOUNDARY."--rn";
Posted by: Guest on March-24-2020
0

get values from text file php

$lines_array = file("file.txt");
$search_string = "bing";

foreach($lines_array as $line) {
    if(strpos($line, $search_string) !== false) {
        list(, $new_str) = explode(":", $line);
        // If you don't want the space before the word bong, uncomment the following line.
        //$new_str = trim($new_str);
    }
}

echo $new_str;

?>
Posted by: Guest on December-18-2021

Browse Popular Code Answers by Language