Results 1 to 11 of 11

Thread: Creating a dynamic Photo Gallery

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2008
    Posts
    5

    Creating a dynamic Photo Gallery

    I'm trying to create a dynamic photo gallery. I want users to be able to upload pictures to a directory then edit a text file in the text file they will specify the file location and a description for the graphic. I then need to create client side script that will retrieve that text file open it and sort all of the CSV entries to create a photo gallery for instance

    Person will upload files to "www.mypage.com/pictures"
    the file is called "picture1"
    the title is "Florida 2007"
    and the caption is "me at the beach"

    and lets say there are 50 or so of these pictures, how do I read the information from the text file and place all of the informaiton into arrays

    pictures(50)
    title(50)
    caption(50)

    I'm hosting the site off of an apache server which doesn't support ASP. And I'm too lazy to learn PHP. Is there a way to do this using a client side script?

    -Chris

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Creating a dynamic Photo Gallery

    Moved to PHP where someone may encourage you or show you a simple way of doing this in PHP (since you said your host doesn't support ASP).

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2008
    Posts
    5

    Re: Creating a dynamic Photo Gallery

    I would prefer to do this is a client side vbscript

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Creating a dynamic Photo Gallery

    Are you aware that the VBScript solution will only work in Internet Explorer and not Firefox?

    Because you're hosting on an Apache server, your VBScript will not have access to the file system on the Apache server itself. And while indeed you could have the VBScript read the text file for information and get the images as well via an HTTP request, you're not going to be able to perform the uploads without some server side scripting. You will also not be able to allow the users to edit the text file on the server, since this is all client side. Not to mention that this, even if it worked, would be an extremely slow solution.

    You will need to look at a server side scripting solution to accomplish what you have mentioned in Post #1.

  5. #5

    Thread Starter
    New Member
    Join Date
    May 2008
    Posts
    5

    Re: Creating a dynamic Photo Gallery

    uploads will be handled in a different manner. I really only need to know how to read the data from a text file and sort them into arrays.

  6. #6

  7. #7

    Thread Starter
    New Member
    Join Date
    May 2008
    Posts
    5

    Re: Creating a dynamic Photo Gallery

    Alright let me make it simple. I need a client side script written in VB script that will be able to access a .CSV file and separate each line into 3 arrays for example

    Mycsvfile.csv
    =============
    IMG00001.jpg, "Me at the beach", "That's me at the jersey shore"
    IMG00002.jpg, "My dog", "My dog playing with her favorite ball"
    IMG00003.jpg, "My cat", "My cat falling off of the radiator"
    =============

    How would I get VB Script to read those values into 3 separate arrays?

  8. #8
    Hyperactive Member xray's Avatar
    Join Date
    Jun 2003
    Location
    EgYpT
    Posts
    312

    Re: Creating a dynamic Photo Gallery

    hi there

    if u can solve this case u will get what u want

    http://www.vbforums.com/showthread.p...53#post3229653

    thanks
    In the name of allah , the beneficent , the merciful

    Say (O Muhammad ): We believe in allah and that which is revealed unto us and that which was revealed unto abraham and ishmael and isaac and jacob and the tribes , and that which was vouchsafed unto moses and jesus and the prophets from their lord . we make no distinction between any of them , and unto him we have surrendered


    ---- Great Sites For You -------------------

    If you want to know some small things about islam ?

  9. #9

    Thread Starter
    New Member
    Join Date
    May 2008
    Posts
    5

    Re: Creating a dynamic Photo Gallery

    I'm starting to get a little annoyed here. Please read carefully. I need the VB code to read from a server side text file and then split it into 3 arrays it has to be done this way please don't send me entire scripts for a photo gallery I have that all completed I just need to know how to read from a server side text file that's it. I appreciate your enthusiasim but it makes more work for me.

  10. #10
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141

    Re: Creating a dynamic Photo Gallery

    See if this gets you started
    Code:
    Option Explicit
    
    Const ForReading = 1
    
    Dim fso
    Dim strFilePath
    Dim ts
    Dim arrPictures
    Dim arrTitle
    Dim arrCaption
    Dim arrLines()
    Dim i
    Dim UB
    
    	strFilePath = "c:\Mycsvfile.csv"
    
    	Set fso = CreateObject("Scripting.FileSystemObject")
    	
    	Set ts = fso.OpenTextFile(strFilePath, ForReading)
    	
    	'Read each line into an array
    	Do While Not ts.AtEndOfStream
    		Redim Preserve arrLines(i)
    		arrLines(i) = ts.ReadLine
    		i = i + 1
    	Loop
    	
    	'Cleanup 
    	ts.Close
    	Set ts = Nothing
    	
    	Set fso = Nothing
    
    
    	'Set the array sizes for the details
    	UB = i - 1
    	Redim arrPictures(UB)
    	Redim arrTitle(UB)
    	Redim arrCaption(UB)
    	
    	'Loop through the lines and add your details to the arrays
    	For i = 0 to UB
    		arrPictures(i) = Split(arrLines(i),",")(0)
    		arrTitle(i)	= Split(arrLines(i),",")(1)
    		arrCaption(i) = Split(arrLines(i),",")(2)	
    	Next
    	
    	
    	'Now just to see if it works
    	Dim strMess
    	
    	For i = 0 to UB
    		strMess = "Line #" & i + 1 & vbcrlf
    		strMess = strMess & "Picture = " & arrPictures(i) & vbcrlf
    		strMess = strMess & "Title = " & arrTitle(i) & vbcrlf
    		strMess = strMess & "Caption = " & arrCaption(i)
    		
    		MsgBox strMess
    	Next

  11. #11
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Creating a dynamic Photo Gallery

    Quote Originally Posted by [email protected]
    I'm starting to get a little annoyed here. Please read carefully. I need the VB code to read from a server side text file and then split it into 3 arrays it has to be done this way please don't send me entire scripts for a photo gallery I have that all completed I just need to know how to read from a server side text file that's it. I appreciate your enthusiasim but it makes more work for me.
    Please read carefully: You cannot access a CSV file on a web server from client side VBScript unless the CSV file is available under an http location.

    If you have an http location available to you, then you will need to do a little more in addition to MarkT's code above. You will first need to get the contents of the CSV file via an HTTP Request. Please confirm that you do have the CSV file available in an http path (a URL).

    You can then get the CSV file like this

    Code:
    'http://blog.netnerds.net/2007/01/vbscript-download-and-save-a-binary-file/
    ' Set your settings
        strFileURL = "http://www.domain.com/file.zip"
        strHDLocation = "D:\file.zip"
     
    ' Fetch the file
        Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
     
        objXMLHTTP.open "GET", strFileURL, false
        objXMLHTTP.send()
     
        If objXMLHTTP.Status = 200 Then
          Set objADOStream = CreateObject("ADODB.Stream")
          objADOStream.Open
          objADOStream.Type = 1 'adTypeBinary
     
          objADOStream.Write objXMLHTTP.ResponseBody
          objADOStream.Position = 0    'Set the stream position to the start
     
          Set objFSO = Createobject("Scripting.FileSystemObject")
            If objFSO.Fileexists(strHDLocation) Then objFSO.DeleteFile strHDLocation
          Set objFSO = Nothing
     
          objADOStream.SaveToFile strHDLocation
          objADOStream.Close
          Set objADOStream = Nothing
        End if
     
        Set objXMLHTTP = Nothing

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width