I hate using java, but ive kinda been forced into using it for this... Right at the moment, it populates a select field with all the images in a directory..... however when the form is submitted to the database, it doesnt save as "name_of_image.gif" it will save as "Name"... so how do I change this, heres the part of the script I believe affect this...
PHP Code:<?
Header("content-type: application/x-javascript");
$pathstring=pathinfo($_SERVER['PHP_SELF']);
$locationstring="http://" . $_SERVER['HTTP_HOST'].$pathstring['dirname'] . "/";
function returnimages($dirname=".") {
$pattern="(\.jpg$)|(\.png$)|(\.jpeg$)|(\.gif$)";
$files = array();
$curimage=0;
if($handle = opendir($dirname)) {
while(false !== ($file = readdir($handle))){
if(eregi($pattern, $file)){
echo 'picsarray[' . $curimage .']="' . $file . '";';
$curimage++;
}
}
closedir($handle);
}
return($files);
}
echo 'var locationstring="' . $locationstring . '";';
echo 'var picsarray=new Array();';
returnimages()
?>Code:function populateSelect(selectobj){ for (var i=0; i<picsarray.length; i++) selectobj.options[selectobj.options.length]=new Option(picsarray[i], picsarray[i]) if (selectobj.options.length>1){ selectobj.selectedIndex=0 showpicture(document.getElementById("picsform").picslist) } }





Reply With Quote
