?
Solved

wget with variable in php

Posted on 2008-10-06
2
Medium Priority
?
1,854 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 Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
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…
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.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

762 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