Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

random images from remote host?

Posted on 2001-07-19
8
Medium Priority
?
258 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
[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
8 Comments
 
LVL 20

Expert Comment

by:Michel Sakr
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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 800 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

610 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