Re: Warning: file_get_contents(): Filename cannot be empty
| From: | Marcos Almeida Azevedo | Date: | Mon, 09 Mar 2015 07:25:44 +0000 |
| Subject: | Re: Warning: file_get_contents(): Filename cannot be empty | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-324596@lists.php.net to get a copy of this message | ||
On Mon, Mar 9, 2015 at 3:06 PM, hadi <almarzuki2011@hotmail.com> wrote:
> Hi every one,
>
> Im getting error while using file_get_contents(): function.
>
> (Warning: file_get_contents(): Filename cannot be empty)
>
> Im using file_get_contents(): function to get urls links from ($convert)
> variable.
>
> Here is my code
>
> <?php
>
>
> error_reporting(E_ALL);
> ini_set("display_errors", 1);
>
>
>
>
> $url = "http://www.sahafah.net/rss.php";
>
>
> $rss = file_get_contents($url);
>
I believe file_get_contents should be used on a local file and not remote
or over http
>
> ini_set('mbstring.substitute_character', "none");
> $rss1= mb_convert_encoding($rss, 'UTF-8', 'UTF-8');
> $rss3 = simplexml_load_string($rss1);
> if($rss3)
> {
> $items = $rss3->channel->item;
> foreach($items as $item)
> {
>
> $title = $item->title;
> $link = $item->link;
> $published_on = $item->pubDate;
> $description = $item->description;
> $category = $item->category;
> $guid = $item->guid;
>
>
>
>
> $string2 = $item->description;
> preg_match('/http.*.jpg/',$string2,$match2);
> $convert = implode(",", $match2);
>
>
>
> // A few settings
>
> // Read image path, convert to base64 encoding
> $imageData = base64_encode(file_get_contents($convert));
>
> // Format the image SRC: data:{mime};base64,{data};
> $src = 'data: '.exif_imagetype($convert).';base64,'.$imageData;
>
> // Echo out a sample image
> echo '<img src="', $src, '">';
>
>
>
>
>
>
>
>
>
> }
>
>
> }
>
>
>
>
>
>
>
> ?>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Marcos | I love PHP, Linux, and Java
<http://javadevnotes.com/java-float-to-string-examples>