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
Solved

wget with variable in php

Posted on 2008-10-06
2
1,697 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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Output in PHP throwing alignment of data off issue 12 43
Awk : two files math 8 20
PHP breaks when used in Wordpress template file 3 31
Ajax and PHP 9 30
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
This article discusses how to create an extensible mechanism for linked drop downs.
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
The viewer will learn how to count occurrences of each item in an array.

829 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