Solved

wget with variable in php

Posted on 2008-10-06
2
1,634 Views
Last Modified: 2012-05-05
Hi,

I am trying to download a file but not getting any output

<?php
$url = "www.site1.com/image/gif//image1.gif";
$command = "wget ".$url;
exec($command, $op);
print_r($op);
?>
I am using Linux OS. wget is installed as I can download the same file using wget on command line.


Even copy is not working.
<?php
$url = "www.site1.com/image/gif//image1.gif";
$localpath = "/home/www/image1.gif";
copy($url,$localpath);
?>
0
Comment
Question by:the_rock3353
2 Comments
 
LVL 6

Accepted Solution

by:
trickyidiot earned 500 total points
ID: 22649862
2 things - you have a double slash in the URI and you need to add 'http://'

<?php
$url = "http://www.site1.com/image/gif/image1.gif";
$command = "wget {$url}";
exec($command, $op);
print_r($op);
?>
0
 
LVL 11

Expert Comment

by:bansidhar
ID: 22651283
try using CURL if possible, because you may not have the luxury to have exec command on good production servers.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now