Solved

wget with variable in php

Posted on 2008-10-06
2
1,724 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Don't miss ATEN at NAB Show April 24-27!

Visit ATEN at NAB Show to learn how our "Seamlessly Entertaining" solutions deliver fast, precise video streaming without delays for the broadcasting and media environment. ATEN will showcase its 16x16 Modular Matrix Switch (VM1600) and KVM Over IP Solution (KE6900 series).

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
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 …

730 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