I'm incredibly frustrated as I can't seem to get past this error, no matter how I try.
My website requires I download a large (zipped) XML product feed - daily. The file size is variable; I get PHP warnings when the product feed is larger. There MUST be a way to resolve this!
The script downloads the file (still zipped) to my server:
<?php
file_put_contents('datafeed.xml.gz', file_get_contents('http://external website.com/format/xml/compression/gzip/'));
Error: PHP Warning: file_get_contents(...): failed to open stream:
HTTP request failed! in... etc.
How do I solve this? Much appreciated!
Related
I'm trying to write the content of a page on my server to a variable using file_get_contents:
$lnk = "https://www.example.com/test%20file.php";
$otpt = file_get_contents($lnk);
The full URL is needed because I need the PHP output of the page and not the PHP script itself.
When running the above code I get this warning: failed to open stream: HTTP request failed! No other information, e. g. HTML error code, is provided. allow_url_fopen is enabled on the server. error_reporting(E_ALL) doesn't show any more information. The only thing which seems mentionable to me is that the file_get_contents request takes much too long (up to 30 secs) for the ~57 KB file I'm currently testing on.
I checked the Reference - What does this error mean in PHP?, but to no avail. I really have no idea what this message means since any further specification by PHP is missing. Any help would be very much appreciated.
Thanks in advance!
I'm processing a large number of zips and can't track down an error.
The problem is that after the import script runs for a while it suddenly stops with an error at a random zip file. If I try to re-run the script for only that single file, it works (so I exclude that the zip is faulty).
The process is like this: Open zip archive, read content, copy images from the zip, close archive.
I have two questions:
1. Why doesn't PHP simply return false instead of throwing the following error:
PHP Error[2]: copy(zip:///path/to/file/319759.zip#nwh1131_1.jpg): failed to open stream: operation failed
Any ideas what the cause can be? Maybe something with the filesystem? (Server is running on Debian 7 wheezy)
Thanks
I've got a fairly simple cron job that pulls down some files from an FTP server - none of the files are particularly large, but I'm constantly getting the following:
Connected to voip.colefabrics.com, for user colefabrics\absolute
Warning: ftp_get(): Opening BINARY mode data connection. in /home/www/colefabrics.com/httpdocs/libs/classes/class.ftpObj.php on line 56
There was a problem while downloading website/items.csv
Attempt 2:
Connected to voip.colefabrics.com, for user colefabrics\absolute
Warning: ftp_get(): Opening BINARY mode data connection. in /home/www/colefabrics.com/httpdocs/libs/classes/class.ftpObj.php on line 56
There was a problem while downloading website/items.csv
...snip...
I've been through all the other posts relating to this, tried to enforce passive mode, increased the timeout, but nothing is working.
Does anyone know what might be causing this, and what I can do to try and resolve it?
To confirm, it's working fine via a 'normal' FTP client, it's only via PHP that I have a problem.
so I'm trying implement a website which uses data stored in an xml file.
It works fine on my computer, but as soon as I try to upload it, I get the following error:
Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity "..\lib\menu.xml" in /home/ogwareco/public_html/menu.php on line 2
And none of the data gets displayed on the screen. I've Googled this problem, but it's led nowhere. I've got no idea what to do here. I've even tried to set my permissions to 777 (bad idea, I know), to see if it was a permissions thing, but it's not.
It looks like you are using backslashes to refer to the file on a Linux machine. Change
..\lib\menu.xml
to
../lib/menu.xml
in your code.
For the longest time now I've been trying to convert HTML pages containing large tables to PHP. These are styled with CSS and can be several pages long.
I first tried DOMPDF. It works great, until a document is more than one page. None of the fixes I've found work. Either it errors out, or any element that would be even partially on the second page gets lumped over the content of page 1. I've tried both the latest release and the SVN copy I checked out today.
I also tried html2ps/pdf, and it gives me "permission denied" errors writing to the cache directory, even though the directory is fully writable. The system requirements test script passes. The server is running PHP 5 under IIS (not my choice heh).
Can either of these be convinced to work, or is there a library that can do it?
Errors from the demo/test scripts:
Warning: file_put_contents(C:\Inetpub\wwwroot\JM\pdf\html2ps\cache/7d888258e9745b3716532ea81342daaf.css.compiled) [function.file-put-contents]: failed to open stream: Permission denied in C:\Inetpub\wwwroot\JM\pdf\html2ps\css.cache.class.php on line 33
Warning: fopen(C:\Inetpub\wwwroot\JM\pdf\html2ps\cache/unicode.lb.classes.dat) [function.fopen]: failed to open stream: Permission denied in C:\Inetpub\wwwroot\JM\pdf\html2ps\inline.content.builder.php on line 991
Warning: flock() expects parameter 1 to be resource, boolean given in C:\Inetpub\wwwroot\JM\pdf\html2ps\inline.content.builder.php on line 992
Warning: fwrite(): supplied argument is not a valid stream resource in C:\Inetpub\wwwroot\JM\pdf\html2ps\inline.content.builder.php on line 1011 (this error repeats several thousand times)
Warning: fopen(C:\Inetpub\wwwroot\JM\pdf\html2ps\cache/times.z) [function.fopen]: failed to open stream: Permission denied in C:\Inetpub\wwwroot\JM\pdf\html2ps\pdf.fpdf.makefont.php on line 318
Can't write to file C:\Inetpub\wwwroot\JM\pdf\html2ps\cache/times.z
A similar problem with html2pdf under IIS has been discussed here.
The solution was quite simple, yet weird. If this doesn't help you, a full error-message and / or a little bit of code would help me to help you.
I personally recommend command line applications instead of any PHP libraries.
Reasons :
PHP libraries need more time and memory (cache) for conversion process.
They need well-formatted HTML pages only, otherwise throw errors or warnings.
No support for external style sheets.
Command Line Tool:
If you run your script on a Linux server then I suggest command line tools.
Reasons :
They are extremely fast compared to PHP libraries.
Support CSS.
Accept non-well-formatted HTML.
Which command line tool to use?
wkhtmltopdf
htmltopdf
html2pdf
For more information refer to Converting HTML to PDF (not PDF to HTML) using PHP.