Saturday, June 1, 2013

Re: File load from server javascript cakephp2

WWW_ROOT is meaningless to javascript. Also, you did not provide your file_exists function. Or are you trying to call the php function of the same name? That won't work. Those paths are all over the place. Of the different paths you tried, the one beginning with '/files' looks the most promising. Is the file sitting inside the app/webroot/files directory? Is it readable? Does your javascript make an AJAX request for the file? (Remember, this code is running in the browser, not on the server.) Can you successfully make AJAX requests for other files?


On Tue, May 28, 2013 at 5:37 PM, <ivan.alberquilla@gmail.com> wrote:


I have a aplication in cakephp2. In home.ctp I wan't to use a javascript function to load a file from filesystem and create a track in a map, but I donn´t know how to locate it.

In the javascript function I declare a var with the name of the file and then I check if the file exists, and always return false.

  var gpxfile='WWW_ROOT.files.DS.hoyo.gpx';    if(file_exists(gpxfile)){      alert('Si existe');  } else {      alert('No existe');   }

I tried with the names:

  var gpxfile='WWW_ROOT.files.DS.hoyo.gpx';    var gpxfile='/app/files/hoyo.gpx';    var gpxfile='/files/hoyo.gpx';    var gpxfile='/webroot/files/hoyo.gpx';

But nothing. How can I locate it?

It is necesary to configure the core.php?

Thanks

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments: