PDA

View Full Version : script src and imagepath in the local host



+[some]+[one]+
05-25-2007, 10:03 PM
1) Script Title: +[PHP Photo Album script]+


2) Script URL (on DD):

http://www.dynamicdrive.com/dynamicindex4/php-photoalbum.htm


3) Describe problem:

Hello evry one,

i liked to try this script on my local host but 2 problems accure ..

1-) i dont know how to pass the script src in the html file ..

i fellowed the instruction and i wrote.

<script src="gallery/getpics.php" type="text/javascript"></script>

as the gallery is the folder which having the whole picture which i want to browes.

2-)i dont know which path i should use as i am using my local host:

var imagepath="????????????????????????"

=================================================

i test the code by passing the same links which are used in the example of Jaguar cars and it work 100% perfect ..

also i am sure that my problem in the above 2 problem as there is a error ( galleryarray is undefined) and this array is defined in (getpics.php)

so the src of the script is not working .. so do tell me how i can pass the right src :confused: and i will be so thankful for you..:o

maight this picture will help to find the correct path.

http://www.alain4ever.com/forum/uploaded/3717_1180130397.jpg






my regards:)

+[some]+[one]+
05-26-2007, 08:09 PM
:( where are you :(

djr33
05-26-2007, 08:34 PM
Is home.html where you are using this script?

It looks like the path is set correctly.

For image path, you should use "gallery", since that will point to where the images are located.

Is PHP functioning correctly on your system? Be sure to load this through your server, not just as a file, since PHP will only parse if it's operating through the server.

Not really sure what else could be the problem.

+[some]+[one]+
05-27-2007, 01:52 PM
yes i used the java script inside home.html .. and i locate the getpics.php inside the gallery folder which contain the pictures..

in the example:

(var imagepath="http://www.mysite.com/gallery/" //Absolute path to image directory. Include trailing slash (/)).

so which path i should give as i am using my localhost??:(

my PHP function are correct as i mention that i tried the same links which is in the Jaguar cars and it was working correctly..

any help i can find :(

djr33
05-27-2007, 07:17 PM
Just use a relative path, as I said. If you're in a folder and in that folder is "gallery" holding the pictures, then the path "gallery", or "gallery/" would do just fine.

+[some]+[one]+
05-28-2007, 07:58 PM
i tried but its not working

any way .. thanks alot

djr33
05-28-2007, 08:02 PM
I see no reason that relative paths shouldn't work.

Perhaps....

'/f1/f2/f3/gallery'

Where f1 is the first folder, f2 is the second, etc., starting at your site's root.
the first slash means "go to site root", then it goes up to the path of the gallery.

Something else is likely wrong, and I'm not sure what.
If you could give us a link or post some code, that might be helpful.

+[some]+[one]+
05-29-2007, 10:28 AM
its not working ... any way thanks for help :)

djr33
05-29-2007, 10:36 AM
No problem.

I have no idea why it isn't working.

Could you link to your page if you have a way of putting it on the net?
Or, if not, post the code, so we know what is wrong.
this is hard to test without seeing it running.

+[some]+[one]+
05-29-2007, 04:09 PM
i dont have a page but i am trying to understand the working of the [PHP Photo Album script] wich is on this link:

http://www.dynamicdrive.com/dynamicindex4/php-photoalbum.htm

1-i download the (getpics.php) and i place it in the gallery folder which is having the whole picture ..

2- i creat html file which its name is (home.htm).

3- i copy past the following code in the body of home.htm

<body>


=======================




<script src="gallery/getpics.php" type="text/javascript"></script>


<script type="text/javascript">


var dimension="3x3" //Specify dimension of gallery (number of images shown), such as 4x2, 3x1 etc
var imagepath="mygallery/gallery/" //Absolute path to image directory. Include trailing slash (/)
var href_target="new" //Enter target attribute of links, if applicable


//Toggle popup link setting: popupsetting[0 or 1, "pop up window attributes" (if 1)]
var popupsetting=[1, "width=500px, height=400px, scrollbars, resizable"]

//Toggle image description: descriptionprefix[0 or 1, "Text to show" (if 1)]
var descriptionprefix=[1, "Photo "]

//Sort images by date? ("asc", "desc", or "")
//"desc" for example causes the newest images to show up first in the gallery
//"" disables this feature, so images are sorted by file name (default)
var gsortorder="desc"

//By default, each image hyperlinks to itself.
//However, if you wish them to link to larger versions of themselves
//Specify the directory in which the larger images are located
//The file names of these large images should mirror those of the original
//Enter a blank string ("") to disable this option
var targetlinkdir=""

/////No need to edit beyond here///////////////////

function sortbydate(a, b){ //Sort images function
if (gsortorder=="asc") //sort by file date: older to newer
return new Date(a[1])-new Date(b[1])
else if (gsortorder=="desc") //sort by file date: newer to older
return new Date(b[1])-new Date(a[1])
}

if (gsortorder=="asc" || gsortorder=="desc")
galleryarray.sort(sortbydate)

var totalslots=dimension.split("x")[0]*dimension.split("x")[1]

function buildimage(i){
var imagecompletepath=(targetlinkdir!="")? targetlinkdir+galleryarray[i][0] : imagepath+galleryarray[i][0]
var tempcontainer='<a href="'+imagecompletepath+'" target="'+href_target+'" onClick="return popuplinkfunc(this)">'
tempcontainer+='<img src="'+imagepath+galleryarray[i][0]+'" title="'+galleryarray[i][0]+' ['+galleryarray[i][1]+']" />'
tempcontainer+='</a><br />'
tempcontainer+=(descriptionprefix[0]==1)? descriptionprefix[1]+(i+1) : ""
return tempcontainer
}

function jumptopage(p){
var startpoint=(p-1)*totalslots
var y=1;
for (i=0; i<totalslots; i++){
document.getElementById("slide"+i).innerHTML=(typeof galleryarray[startpoint+i]!="undefined")? buildimage(startpoint+i) : ""
}
while(document.getElementById("navlink"+y)!=null){
document.getElementById("navlink"+y).className=""
y++
}
document.getElementById("navlink"+p).className="current"
}

var curimage=0
for (y=0; y<dimension.split("x")[1]; y++){
for (x=0; x<dimension.split("x")[0]; x++){
if (curimage<galleryarray.length)
document.write('<div id="slide'+curimage+'" class="slideshow">'+buildimage(curimage)+'</div>')
curimage++
}
document.write('<br style="clear: left" />')
}

function popuplinkfunc(imgsrc){
if (popupsetting[0]==1){
var popwin=open(imgsrc.href, "popwin", popupsetting[1])
popwin.focus()
return false
}
else
return true
}

</script>

<!--Below HTML code refers to the navigational links for the gallery-->

<div id="navlinks">
<script type="text/javascript">
for (i=1; i<Math.ceil(galleryarray.length/totalslots)+1; i++)
document.write('<a id="navlink'+i+'" href="javascript:jumptopage('+i+')\">Page'+i+'</a> ')
document.getElementById("navlink1").className="current"
</script>
</div>

</body>


======

my problem is in this 2 parts of the code

A)- <script src="gallery/getpics.php" type="text/javascript"></script>

B)- var imagepath="mygallery/gallery/" //Absolute path to image directory. Include trailing slash (/)



=============

whem i am trying to preview in the FrontPage its showing me error that the (the galleryarray is undefind ), and this array is defind in (getpics.php) .. so i got that the linking the javascript code its not working in home.htm

+[some]+[one]+
05-29-2007, 04:15 PM
i dont have a page but i am trying to understand the working of the [PHP Photo Album script] wich is on this link:

http://www.dynamicdrive.com/dynamicindex4/php-photoalbum.htm

1-i download the (getpics.php) and i place it in the gallery folder which is having the whole picture ..

2- i creat html file which its name is (home.htm).

3- i copy past the following code in the body of home.htm





=======================




<body>

<script src="gallery/getpics.php" type="text/javascript"></script>


<script type="text/javascript">


var dimension="3x3" //Specify dimension of gallery (number of images shown), such as 4x2, 3x1 etc
var imagepath="mygallery/gallery/" //Absolute path to image directory. Include trailing slash (/)
var href_target="new" //Enter target attribute of links, if applicable


//Toggle popup link setting: popupsetting[0 or 1, "pop up window attributes" (if 1)]
var popupsetting=[1, "width=500px, height=400px, scrollbars, resizable"]

//Toggle image description: descriptionprefix[0 or 1, "Text to show" (if 1)]
var descriptionprefix=[1, "Photo "]

//Sort images by date? ("asc", "desc", or "")
//"desc" for example causes the newest images to show up first in the gallery
//"" disables this feature, so images are sorted by file name (default)
var gsortorder="desc"

//By default, each image hyperlinks to itself.
//However, if you wish them to link to larger versions of themselves
//Specify the directory in which the larger images are located
//The file names of these large images should mirror those of the original
//Enter a blank string ("") to disable this option
var targetlinkdir=""

/////No need to edit beyond here///////////////////

function sortbydate(a, b){ //Sort images function
if (gsortorder=="asc") //sort by file date: older to newer
return new Date(a[1])-new Date(b[1])
else if (gsortorder=="desc") //sort by file date: newer to older
return new Date(b[1])-new Date(a[1])
}

if (gsortorder=="asc" || gsortorder=="desc")
galleryarray.sort(sortbydate)

var totalslots=dimension.split("x")[0]*dimension.split("x")[1]

function buildimage(i){
var imagecompletepath=(targetlinkdir!="")? targetlinkdir+galleryarray[i][0] : imagepath+galleryarray[i][0]
var tempcontainer='<a href="'+imagecompletepath+'" target="'+href_target+'" onClick="return popuplinkfunc(this)">'
tempcontainer+='<img src="'+imagepath+galleryarray[i][0]+'" title="'+galleryarray[i][0]+' ['+galleryarray[i][1]+']" />'
tempcontainer+='</a><br />'
tempcontainer+=(descriptionprefix[0]==1)? descriptionprefix[1]+(i+1) : ""
return tempcontainer
}

function jumptopage(p){
var startpoint=(p-1)*totalslots
var y=1;
for (i=0; i<totalslots; i++){
document.getElementById("slide"+i).innerHTML=(typeof galleryarray[startpoint+i]!="undefined")? buildimage(startpoint+i) : ""
}
while(document.getElementById("navlink"+y)!=null){
document.getElementById("navlink"+y).className=""
y++
}
document.getElementById("navlink"+p).className="current"
}

var curimage=0
for (y=0; y<dimension.split("x")[1]; y++){
for (x=0; x<dimension.split("x")[0]; x++){
if (curimage<galleryarray.length)
document.write('<div id="slide'+curimage+'" class="slideshow">'+buildimage(curimage)+'</div>')
curimage++
}
document.write('<br style="clear: left" />')
}

function popuplinkfunc(imgsrc){
if (popupsetting[0]==1){
var popwin=open(imgsrc.href, "popwin", popupsetting[1])
popwin.focus()
return false
}
else
return true
}

</script>

<!--Below HTML code refers to the navigational links for the gallery-->

<div id="navlinks">
<script type="text/javascript">
for (i=1; i<Math.ceil(galleryarray.length/totalslots)+1; i++)
document.write('<a id="navlink'+i+'" href="javascript:jumptopage('+i+')\">Page'+i+'</a> ')
document.getElementById("navlink1").className="current"
</script>
</div>

</body>



======

my problem is in this 2 parts of the code

A)- <script src="gallery/getpics.php" type="text/javascript"></script>

B)- var imagepath="mygallery/gallery/" //Absolute path to image directory. Include trailing slash (/)




=============

whem i am trying to preview in the FrontPage its showing me error that the (the galleryarray is undefind ), and this array is defind in (getpics.php) .. so i got that the linking the javascript code its not working in home.htm



=========

as i show in the main post the full path for home.htm so what will be the exact path so the code will work in my localhost ??




=================