I am trying to formulate a URL to use to set the src
property of an img
control. I first build a file path passing PHP to a javascript variable:
var image_path_name = "<?php $path = VENUE_IMAGES_PATH . DS; echo (string) $path; ?>";
When I look at the page source, this shows up as:
var image_path_name = "http:\\127.0.0.1\where2bwho2c\w2bw2c-admin\public\images\venues\";
This looks correct, but I am getting a "Invalid or unexpected token" error on this line of code.
If I do a console.log
with the PHP,
console.log(<?php $path = VENUE_IMAGES_PATH . DS; echo (string) $path; ?>);
I get an "Uncaught SyntaxError: missing ) after argument list" error. How can I build a valid URL without getting these errors?