Vz19JDw3ExqZ Posted December 17, 2013 Report Share Posted December 17, 2013 Am un array in javascript de acest fel:img = new Array('upload/img1.jpg','upload/img2.jpg');si as vrea sa am ceva de genul:img = new Array('upload/"<?php echo $post_img1; ?>"', 'upload/"<?php echo $post_img2; ?>"'');cum as putea face chestia asta?Adica vreau sa preiau cu php numele imaginii postate si sa o adaug in array-ul javascript. Quote Link to comment Share on other sites More sharing options...
EAdrian Posted December 17, 2013 Report Share Posted December 17, 2013 (edited) <html> <body> <script type="text/javascript"> var array = new Array( 'upload/'<?php echo urlencode($post_img1); ?>, 'upload/'<?php echo urlencode($post_img2); ?> ); </script> </body></html>PS: Asta doar dac? codul javascript este incorporat în fi?ierul PHP... dac? nu, po?i folosi post, get Edited December 19, 2013 by EAdrian GarryOne is right Quote Link to comment Share on other sites More sharing options...
GarryOne Posted December 17, 2013 Report Share Posted December 17, 2013 (edited) Nu ai fost prea explicit de aceea nici nu am inteles mare lucru.Relateaza mai in detalii cum se intampla actiunea.Cum vrei s-o iei, dupa ce se face submit? Daca da, pui pur si simplu "img = new Array('upload/'.$_FILES['file']['name'].');"@EAdrian, tu practic ai rescris inca o data ce a scris el in primul post.Si unde e chestia aia:'upload/'+ <?php echo urlencode($post_img1); ?>nu ai de ce sa pui plus pentru ca nu concatenezi cu cod javascript. Corect ar fi'upload/<?php echo urlencode($post_img1); ?>' Edited December 17, 2013 by GarryOne Quote Link to comment Share on other sites More sharing options...
endemic Posted December 18, 2013 Report Share Posted December 18, 2013 oameni buni .. <?php$cale = "upload/";$imagini = array();$imagini[] = $cale."banane.jpg";$imagini[] = $cale."test.png";?><script> var img = <?=json_encode($imagini);?>;</script> Quote Link to comment Share on other sites More sharing options...
Vz19JDw3ExqZ Posted December 18, 2013 Author Report Share Posted December 18, 2013 Merci frumos am rezolvat! Quote Link to comment Share on other sites More sharing options...