Solved

random images from remote host?

Posted on 2001-07-19
8
233 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Smart quotes being changed on insert 9 49
How to solve this equation 3 52
Update static table with two columns and multiple rows... 15 83
API not working 33 55
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 …
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

914 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now