We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19153
    • 53 Posts

    I'm hoping this is quite easy to do in Modx. How would I go about making a simple website where users can upload images that could then be displayed in a gallery?

    For example a simple site like http://logopond.com/ although i don't need a login system, perhaps just a captcha. So basically just a form that submits the photo and some information.

    Are there any snippets available or an easy way of accomplishing this?
      • 4172
      • 5,888 Posts
      search for 'upload formit' in this forum. You will find more than one working solutions.
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 19153
        • 53 Posts
        Thanks Bruno17

        formit2file and formit2resource have proved a pretty good solution.

        However I don't think they quite solve my problem. I still need a way of getting the uploaded image to show in the new resource. Perhaps the new path would be somehow passed into an image Template Variable.

        I havent found any solutions to this on the forum as far as I can see
          • 4172
          • 5,888 Posts
          you can load all images into one folder and store the path into a formit-hook-value ($hook->setValue) and get this value by formit2resource to save the value into a TV.
          Or you can create a new directory by formit2resource for each resource and move the image into that folder by formit2file (reversed hook-order!) .
          Than you don't need a TV to get the Resources image(s)
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 19153
            • 53 Posts
            Thanks!

            I am a designer and don't know php so am trying to cobble this together.

            So far I have added a hidden image TV value to my form html:

            <input id="image" name="image" type="hidden" value="[[+fi.image]]" />


            Then I inserted the new last line in my formit2file snippet

             // clean up file name and make unique
                        $filename = mb_strtolower($filename); // to lowercase
                        $filename = str_replace(' ', '_', $filename); // spaces to underscores
                        //$filename = date("Y-m-d_G-i-s_") . $filename; // add date & time
                          
                        // full path to new file
                        $myTarget = $target_path . $filename;
            
                        $hook->setValue('image','$myTarget');
            
            


            However the line - $hook->setValue('image','$myTarget'); is adding just the text $myTarget to the TV, this is great as something is being added to the TV but obviously not the generated path.

            So clearly my php here is wrong. I just need to have the myTarget value inserted here, what am i doing wrong?



              • 19153
              • 53 Posts
              ok I fixed this the correct syntax is with quotes:

              $hook->setValue('image',$myTarget);


              the only problem now is that it is generating a full path eg

              /home2/databse/public_html/website/assets/uploads/2012-04-11/image24242.jpg

              This is looking very promising now if i can just strip out the start of the path
                • 4172
                • 5,888 Posts
                remove the part, where the date is putten in the path and try:

                $hook->setValue('image',$filename);
                [ed. note: Bruno17 last edited this post 14 years, 6 months ago.]
                  -------------------------------

                  you can buy me a beer, if you like MIGX

                  http://webcmsolutions.de/migx.html

                  Thanks!