Solved

random images from remote host?

Posted on 2001-07-19
8
236 Views
Last Modified: 2008-03-17
I have a site that pulls random images from my own server, this is no problem...

I would like to provide people with the ability to add their own random photos... However I do not want to host these images... I want, what seemed simple enough, for them to provide me with a url where they can be found.

I have forms in place that when filled out place a cookie on the users machine, containing the URL to the folder full of images...

I also have no problem reading that url...  I have it stored in a variable called "mypath"  the problems occur when using the next lines of code:

Set folder = filesystem.GetFolder(server.mappath(mypath))
Set filesystem = CreateObject("Scripting.FileSystemObject")
Set filecollection = folder.Files


I fully understand that when using mappath, it maps whatever server the asp file resides on... along with the FileSystemObject and the ability to see those files.

I can find no alternative to actually mapping the server...  I want the ability to name my image files whatever I'd like (as opposed to just numbers) and eventually the ability to allow shockwave files to be pulled at random also.

Essentially, I want to pull random images from remote hosts...

i hope this makes sense...
0
Comment
Question by:ghettocooler
8 Comments
 
LVL 20

Expert Comment

by:Silvers5
ID: 6301090
first:
Set filesystem = CreateObject("Scripting.FileSystemObject")
Set folder = filesystem.GetFolder(server.mappath(mypath))
Set filecollection = folder.Files

second: the above is useless.. you can't map a file on a remote server from the url provided.. you can't view the file using fso ... your best solution is to fetch the image using a component or the XMLObjects:

How do I read the contents of a remote web page?    
You can include static txt and HTML files from remote servers by using a component (such as AspHTTP (http://www.serverobjects.com/products.htm), ASPTear (http://www.alphasierrapapa.com/ComponentCenter/AspTear/), or VB's built in InetCtrls) to parse the remote URL's content.
 
You can also try this method out, it uses the MSXML objects which are installed with Windows 2000 (or you can download them here (http://download.microsoft.com/download/xml/Install/3.0/WIN98Me/EN-US/msxml3.exe) for other operating systems):
 
<%
    url = "http://www.espn.com/
    set xmlhttp = server.CreateObject("Microsoft.XMLHTTP")
    xmlhttp.open "GET", url, false
    xmlhttp.send "" 
    Response.write xmlhttp.responseText
%>

0
 
LVL 7

Expert Comment

by:weesiong
ID: 6301122
ghettocooler,

In the first case, you need to know the images name in your remote server. and later it:

<%
Randomize
MYImage = Int((6 * Rnd) + 1) 'you have 6 images in remote server
MYImage = MYImage & ".gif"
%>

img src="http://www.remoteserver.com/<%=MYImage%>">

Regards,
Wee Siong
0
 

Author Comment

by:ghettocooler
ID: 6301956
How can I not limit, or specify the number of images?...  Whatever's in the folder on the remoteserver; pull at random... (gifs or Jpgs)
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 7

Expert Comment

by:weesiong
ID: 6304263
ghettocooler,

no sure you can do it, because at less you want to know the name for the remoteserver, and you just can do it :)

So tell me more about your remoteserver info, i will give the suggestion :)

Regards,
Wee Siong
0
 

Author Comment

by:ghettocooler
ID: 6306228
If I could only translate this from english to asp...


<%
randomSRC = Any file in the folder named Random at this url(http://www.theURLISelected.com) ending in .gif, or .jpeg
%>

<img src="<%= randomSRC %>">

When working with randomizing files; Does asp require you to creata a fileCollection?; So it can kind of scan through every file?



0
 
LVL 7

Accepted Solution

by:
weesiong earned 200 total points
ID: 6307064
ghettocooler,

No, this is easy as like you say:
<img src="<%= randomSRC %>">

but the problem now you "canot know" how many files in the server, and it means you "canot know" the files name for server :(

Regards,
Wee Siong
0
 
LVL 33

Expert Comment

by:hongjun
ID: 8623269
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
[points to weesiong]

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

hongjun
EE Cleanup Volunteer
0
 

Expert Comment

by:Chmod
ID: 8674361
As recommended

Chmod
Community Support Moderator @Experts Exchange
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

Suggested Solutions

Title # Comments Views Activity
Recordset containing single quotes 8 43
Obtaining data on ASP 8 28
VBScript on Html 15 47
XML and version of MS XML Dom Document versions 4 10
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
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…

861 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