问题
I have some images in a folder called "Slides" in my project; I am trying to access those images; but it gives me the following error:
Not allowed to load local resource: file:///C:/xampp/htdocs/MyProject/Slides/123_completed.jpg
where is "file://" coming from?! (Probably thats the problem!)
this is my method to scan the images in the folder called "Slides"
the following line of code is in my
$this->signage_Path = realpath(APPPATH . '../Slides');
public function get_Signage_Images() {
$files = scandir($this->signage_Path);
$newFiles = array_diff($files, array('.', '..'));
$images = array();
foreach ($newFiles as $file) {
$ext = pathinfo($file, PATHINFO_EXTENSION);
if ($ext == "jpg") {
$images[] = array(
'url' => $this->signage_Path.'\\'.$file,
'thumb_url' => $this->signage_Path.'\\'.$file,
);
}
}
return $images;
}
If you need more clarification, please let me know which part!
Thanks
回答1:
It's probably coming from your APPPATH
constant in realpath()
. Should be more like $this->signage_Path = 'MyProject/Slides'
, without realpath()
. PHP cannot access a file that is not on a Server, without Client permission. Of course, I really don't know what your sinage_Path
is supposed to be. This should just give you an idea of your problem.
来源:https://stackoverflow.com/questions/20434624/not-allowed-to-load-local-resource-file