I am a novice, and I am trying to learn. First of all, on my Javascript code in the same file, it does NOT recognize a path when specified as c:/wamp/www
. I need to use /videolibrary/
instead (which is configured in httpd.conf
). Now, I need to pass a list of files from PHP which sees it as C:/wamp/www...
and does not understand /videolibrary/
. This is the code I have;
$videolibrary = "C:/wamp/www";
$filelist = array();
$filelist = glob("$videolibrary/$usr/*.webm");
$arrlength = count($filelist);
foreach ($filelist as $file)
{
echo $file;
}
Now, how, do I use this $filelist
on Javascript wherein its values are like {/videolibrary/1.jpg, /videolibrary/2.jpg....}
instead of {c:/wamp/www/1.jpg, c:/wamp/www/2.jpg....}
. Please help. On the JS side;
fl1 = <?php echo json_encode($filelist);?>;
for (i=1; i < sources.length; i++) {
sources[i]=fl1[i-1]; //however this has c:/wamp/www and NOT /videolibrary
var srcName=sources[i];
}
Thank you for the help.
After I posted the question, a wave of enthusiasm took over me and I solved this myself. I did this;
foreach ($filelist as $file)
{
$file1=str_replace($search,$replace,$file);
$filelist1[]=$file1;
}
foreach ($filelist1 as $file1){
echo $file1;
}
Now, I could pass the modified $filelist1 as the array to Javascript. Yes. Here search is the string to search and replace is the string to replace (/videolibrary/).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.