/    Sign up×
Community /Pin to ProfileBookmark

fopen external url

Hello,

I’m trying to load an external file so I can copy the contents onto our server. I have something setup like this, but it doesn’t read anything … no errors either.

[CODE]
<?php
$sourceFile = “https://external.domain.com/?id=123&paramter=xyz&ext=.csv”;
$sourceFileHandler = fopen($sourceFile, “r”);
$sourceFileContent = fread($sourceFileHandler,filesize($sourceFile));
echo $sourceFileContent;
?>
[/CODE]

If I made the $sourceFile local, it works perfect. Ex:

[CODE]$sourceFile = “file.csv”;[/CODE]

Any ideas?

Thanks.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@ralphchadkirkApr 13.2011 — Probably something in the config preventing cross site fopen() calls to prevent security breaches.
Copy linkTweet thisAlerts:
@mikeroqApr 13.2011 — If allow_url_fopen is set to false in php.ini it should produce an error on runtime when you try to open a remote file.

Make sure the external file exists also. Put error_reporting to E_ALL to make sure you are getting errors.
×

Success!

Help @cbVision spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...