php-general Digest 9 Dec 2009 14:39:28 -0000 Issue 6478
Topics (messages 300326 through 300331):
(Slide Show) Developing PHP Web Applications with the Raxan Framework
300326 by: Raymond Irving
Re: Force-Saving an Audio File
300327 by: Gaurav Kumar
file_get_contents ($file) works -- file_get_contents ($url) returns false
300328 by: René Fournier
300329 by: Richard Quadling
300330 by: kranthi
Where you are wanted!
300331 by: promoaction.hush.ai
Administrivia:
To subscribe to the digest, e-mail:
[email protected]
To unsubscribe from the digest, e-mail:
[email protected]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
Hello Everyone,
I've put together a quick slide show for those who are interested in learning
about Raxan for PHP. It only takes a minute or two
Here's the url: http://tinyurl.com/yhdqc9k
Best regards
__
Raymond Irving
--- End Message ---
--- Begin Message ---
You can do two things-
1. Read the file by providing a base directory path of the server where the
file exist.
Something like- //htdocs/httpfolder/files/audio/yourfile.mp3
You can take this in a variable " //htdocs/httpfolder/files/audio/".
2. Try using file_get_contents.
Something like $file = file_get_contents('
http://www.example.com/audio/file.mp3', false, $context);
Hope this helps.
Gaurav Kumar
Blog.OsWebStudio.com
On Wed, Dec 9, 2009 at 8:06 AM, [email protected] <[email protected]
> wrote:
> Hi folks,
>
> I'm trying to force save .mp3 files so this is a test page (found on the
> net). It works fine when:
> $directory = ""; // so the audio is in the same local directory
>
> but fails when I use a REAL web directory - (the audio file is here -
> http://mysite.com/test1/audio.mp3 )
> $directory = "http://mysite.com/test1/";
>
> says - The file $file was not found.
>
> Q: Any ideas how to get it to download from the website?
>
> =====
>
>
>
> <?php
>
> $file = 'audio1.mp3';
>
> $directory = "http://mysite.com/test1/";
> //$directory = "";
> $path = "$directory$file";
>
> if(ini_get('zlib.output_compression'))
> ini_set('zlib.output_compression', 'Off');
>
> $file_extension = strtolower(substr(strrchr($path,"."),1));
>
> if( $file == "" )
> {
> echo "<html>
> <head>
> <title>File not found.</title>
> </head>
> <body>
> File not found.
> </body>
> </html>";
> exit;
> } elseif (! file_exists( $path ) )
> {
> echo "<html>
> <head>
> <title>The file $file was not found.</title>
> </head>
> <body>
> The file $file was not found.<br />
> - path - $path
> </body>
> </html>";exit;
> };
> switch( $file_extension )
> {
> case "pdf": $ctype="application/pdf"; break;
> case "zip": $ctype="application/zip"; break;
> case "doc": $ctype="application/msword"; break;
> case "xls": $ctype="application/vnd.ms-excel"; break;
> case "ppt": $ctype="application/vnd.ms-powerpoint"; break;
> case "gif": $ctype="image/gif"; break;
> case "png": $ctype="image/png"; break;
> case "jpeg":
> case "jpg": $ctype="image/jpg"; break;
> case "wav":
> case "mp3": $ctype="application/iTunes"; break;
> default: $ctype="application/force-download";
> }
> header("Pragma: public");
> header("Expires: 0");
> header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
> header("Cache-Control: private",false);
> header("Content-Type: $ctype");
> header("Content-Disposition: attachment; filename=\"".basename($path)."\";"
> );
> header("Content-Transfer-Encoding: binary");
> header("Content-Length: ".filesize($path));
>
> readfile("$path");
> exit();
>
> ?>
>
>
>
> Thanks,
> [email protected]
>
>
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
Strange problem I'm having on Mac OS X Server 10.6 running PHP 5.3. Any call of
file_get_contents() on a local file works fine -- the file is read and
returned. But any call of file_get_contents on a url -- any url, local or
remote -- always returns false.
var_dump (file_get_contents ('http://www.google.com/'));
bool(false)
I've checked php.ini, and the obvious seems okay:
allow_url_fopen => On => On
Any ideas?
...Rene
--- End Message ---
--- Begin Message ---
2009/12/9 René Fournier <[email protected]>:
> Strange problem I'm having on Mac OS X Server 10.6 running PHP 5.3. Any call
> of file_get_contents() on a local file works fine -- the file is read and
> returned. But any call of file_get_contents on a url -- any url, local or
> remote -- always returns false.
>
> var_dump (file_get_contents ('http://www.google.com/'));
>
> bool(false)
>
> I've checked php.ini, and the obvious seems okay:
>
> allow_url_fopen => On => On
>
> Any ideas?
>
> ...Rene
If you enable all errors, anything extra? ...
<?php
error_reporting(-1);
ini_set('display_errors', 1);
set_time_limit(0); // Just in case it takes more than your default
execution time.
var_dump(file_get_contents('http://www.google.com'));
--
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling
--- End Message ---
--- Begin Message ---
may be unrelated to your problem... but are you behind a proxy?
--- End Message ---
--- Begin Message ---
[url="http://iwantsex.110mb.com"]Online speed dating
iwantsex.110mb.com[/url] allows users to participate in 5 minute
webcam based dates. Also offers speed dating reviews, personal ads
and custom profiles.
Welcome to http://iwantsex.110mb.com
--- End Message ---