I wanna copy some doc files from a link. But, sometimes there’s link that we don’t have permission to access or the link that expired. For the link that we don’t have permission, is there a solution?
and I wanna change the error message when it happen, the error message that I get is :
Warning: copy(http://www-cgi.cs.cmu.edu/afs/cs.cmu.edu/Web/People/ngm/15-721/summaries/12.pdf) [function.copy]: failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden in D:\AppServ\www\academicopter\functionWrapper.php on line 33
I’ve tried to change the error message with (or die ('CANNOT COPY')) the code below :
copy($Link, $savePath . basename($Link)) or die ('CANNOT COPY');
but, the error message still same warning ..... how to change it? thank you 🙂
You can muffle the warning using the
@operator. Note that it would still run any custom error handler you may have configured.AFAIK there’s no other way to get rid of the warning unless you use cURL to copy the file instead.
Edit
You could also use
get_headers($url)and look forHTTP/x.x 403. It’s one more request and personally I would save myself the trouble 🙂