Jump to content

Rudovich

Members
  • Posts

    1
  • Joined

  • Last visited

Posts posted by Rudovich

  1. Hello everyone,

     

    I am trying to create a simple slideshow to learn javascript and a small amount of PHP. People are meant to simply upload a photo to their site using for example Filezilla. The website should automaticly take the photo into the slideshow.

     

    I am still very novice though.

     

    So far I got:

    + PHP to read the file names in the folder.

    + Javascript to take over the PHP Array.

     

    That is not much.. but I already run into a mistake in the next part.

     

    <?php            $PhotoSlideAll = scandir('./photos');            $PhotoSlide = array_diff($PhotoSlideAll, array('.', '..'));?>
    <script>            var SlideShow = ["<?php echo join("", "", $PhotoSlide); ?>"];            var SSl=SlideShow.length - 1;            var picture = "'../photos/" + SlideShow[0] + "'"            document.getElementById("backgroundswitch").style.backgroundImage = "url(picture)";</script>

    Now somehow, it doesn't actually change the background. Whilst the variable picture is really '../photos/PHOTONAME.jpg' when I use an Alert to test it.

     

    Edit: Thank you in advance ;)

×
×
  • Create New...