473,396 Members | 2,011 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

finding the full path of an image ?

I want to list all images from a url.

here is my code snippet which finds an image from a url:

$url = "http://asdf.com/";

$text = @implode("", file($url));

while (eregi("[:space:]*(src)[:space:]*=[:space:]*([^ >]+)", $text , $regs))
{
echo $regs[2];
$text = substr($text, strpos($text, $regs[1]) + strlen($regs[1]));
}

the only problem is that I would like to have it full path but sometimes I
get stuff like:

"../images/test.jpg"

how can I get all images with full path ?
Jul 17 '05 #1
1 1678
Yang wrote:
while (eregi("[:space:]*(src)[:space:]*=[:space:]*([^ >]+)", $text ,
$regs)) {
echo $regs[2];
$text = substr($text, strpos($text, $regs[1]) + strlen($regs[1]));
}

This will also catch links like:

<script src='foo.js' />
the only problem is that I would like to have it full path but
sometimes I get stuff like:

"../images/test.jpg"

how can I get all images with full path ?


What you could do, is prepend the host and the path and apply preg_replace
in a while loop to replace "dirname/.." sections as follows:

$url = "http://www.example.com/somedir/../images/test.jpg";

while (strstr($url, "/../")) {
$url = preg_replace("|/[^/]+/\.\./|", "/", $url);
}

However, there are more rules to consider. Per example, links like
"//images.example.com/images/whatever.gif". In this case, you should only
preprend "http:" to make the link valid.

The following file gives you an idea:

http://playground.jwscripts.com/imagegrab.phps
JW

Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Don | last post by:
How do I retrieve the full path (C:\.....filename) of a file uploaded to a php script on the server. I think $_FILES will only provide 'name', which is only the filename itself. Thanks, Don ...
4
by: Hal Vaughan | last post by:
I want to have a config file for my program, which means I need to know where the config file is. If I type: java myclass and it runs myclass.class, is there any way to obtain the location of...
11
by: Fuzzyman | last post by:
What's the best, cross platform, way of finding out the directory a script is run from ? I've googled a bit, but can't get a clear answer. On sys.argv the docs say : argv is the script name...
3
by: Bill Brother | last post by:
Is it possible to retrieve the local full path of an image ( not the url )?
2
by: Nathan Sokalski | last post by:
I have a rollover script that I plan to use for many of my pages. When I preload the images, the directories must be relevant to the location of the HTML file that uses the script, which will not...
4
by: m | last post by:
Hello I need to find out full URL of my application name, I tried using Request.ServerVariables but it returns only serverername, and I need virtual directory name as well. Thnx in advance
5
by: Jay | last post by:
Hello, I am writing a c++ program that stores some values in a config located in it's directory. is there a way in c++ to get the full path of the running program so I can open the file not...
1
by: Rico | last post by:
Hello, I have an ole object field (Access XP/2002) which I store images in. I have a couple of questions regarding this; is it possible to determine the image dimensions? Secondly, is there...
2
by: =?Utf-8?B?U2hhbQ==?= | last post by:
Hai, I am developing application which handles to create thumbnail form a video file. I am successfully created image and i displayed it into browser by, bit.Save(Response.OutputStream,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.