[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

wget with variable in php

Posted on 2008-10-06
2
Medium Priority
?
1,919 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 2000 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

650 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