We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 41583
    • 29 Posts
    Hi All,

    Environment:
    MODX Revolution 2.2.5-pl
    Ubuntu 12.04 LTS
    Apache/2.2.22
    PHP Version 5.3.10 (128Mb)
    Mysql 5.5.24



    Modx Addons
    getResources 1.5.1
    Login 1.8.1
    NewsPublisher 1.4.2
    Personalize 3.4.0

    I don't think my problem is a technical one its more of a "picnic". I am trying to allow users to upload a profile photo when editing their profile.
    I have added the following to my "edit profile" page
    <label for="photo">[[%photo]]
                <span class="error">[[+error.photo]]</span>
            </label>
           <li> <input type="file" name="photo:optional" id="photo" value="[[+photo]]" /></li>

    This is allowing me to choose a file to upload, but when I actually upload the file, it only records the file name and does not actually upload the file.
    I have checked my entire file system and cannot find the file anywhere, and in the extended fields column of the user it lists photo:optional - Filename.jpg


    When using [[+photo]] in my documents, it only display the filename and if I wrap it within <img> tags, nothing.

    I am most likely just doing it wrong. I have checked and all directories are writable.

    thanks
    Charles



      • 36561
      • 38 Posts
      Quote from: ankh2054 at Nov 28, 2012, 07:21 AM

      When using [[+photo]] in my documents, it only display the filename and if I wrap it within <img> tags, nothing.

      So the filename is the name of the actual image?
      If that's the case, and you get an empty image, after wrapping it with <img>, maybe the path to the file is wrong.

      What's the output of [[+photo]] and what does the <img> tag look like?
        • 41583
        • 29 Posts
        Yes when I use [[+photo]] I only get the filename.

        Below is the code in my view profile page:
        [[+photo]] 
        </br>
        <img src="[[+photo]]" />
        


        I have attached a screenshot.

        I can't seem to find the image anywhere on the filesystem either. Its almost like its not uploading.
        • This is marked answered, but the answer is a question, which is answered, but not followed by anything.

          What is the answer???
            Frogabog- MODX Websites in Portland Oregon
            "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
            Having server issues? These guys have MODX Hosting perfected - SkyToaster
            • 41583
            • 29 Posts
            No answer yet im afraid. I have removed that as being the answer, not sure how that happened.
            • I could be wrong, but I don't really see any way for your code to actually upload a file.

              Have you looked at the fileUpload extra? Methinks you need something like that if you're looking to upload files. I haven't used fileUploadR but it too would be worth a look at.

              The fileUpload prefix is always good for a bonus mid-day (night) chuckle while developing...
                Frogabog- MODX Websites in Portland Oregon
                "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
                Having server issues? These guys have MODX Hosting perfected - SkyToaster
                • 41583
                • 29 Posts
                thanks, ill have a look at it smiley That make sense as nothing is being uploaded. Clearly showing my newbie colours....
                  • 42146
                  • 73 Posts
                  I'm looking at doing the same thing. I need profile image, ideally a set of images / vids.... any new developments?
                  Your code doesn't upload anything. frogabog is correct there. it does save the filename in a extended field....

                  though like me, you probably want to have the user images uploaded into a user dir. i've been looking at http://forums.modx.com/thread/44067/revolution-create-a-folder-based-on-newly-registered-username#dis-post-436488 on how to make the user dir creation happen.... i was hoping there was a way to make Upload to Users CMP on the front end work, which may be a nice solution.. but my php skills are lacking...

                  fileUpload can upload a files to a dir. i was able to get a file into a user dir say... assests/userfiles/(userid#)
                  [[!FileUpload?
                  &filefields=`1`
                  &path=`assets/userfiles/[[+modx.user.id]]` & possible if in the login snippits. &path=`assets/userfiles/[[+id]]
                  ]]


                  though i have found if i put file upload on the same page as update profile. once i upload the file the rest of the update form gets saved. I have yet to try using a posthook on the update. The issue i have not been able to figure out is how to save that path and file name,into the [[+photo]] extended field, for a later call in a <img> tag. perhaps use addon FileLister to then list all files in &path=`assets/userfiles/[[+modx.user.id]] and then output with a tpl as needed?

                  I've done alot of searching and yet to find a profile image solution other than the extra gravatar which users of my site wont want to go to gravatar to sign up just to get a profile image... I'd be more than happy to contribute anything i get working to the community. perhaps get it as a new feature for the login extra.
                  • FileUpload can create a directory upon upload.
                    &createpath If set, upload directory will be created Default=`No`

                    The docs don't specify what directory will be created, or where when you set this parameter to "yes" though.

                    Would it be possible to not put the file into a user directory, but rather another that is reserved for profile images? Then you wouldn't have to set the path, but only find a way to pull the image out.

                    Profile images are something I've got on my list to learn for a couple different projects, so if you do figure something out please report back.
                      Frogabog- MODX Websites in Portland Oregon
                      "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
                      Having server issues? These guys have MODX Hosting perfected - SkyToaster
                      • 42146
                      • 73 Posts
                      I've found photo * A Login.UpdateProfile post hook to allow users to upload a photo for their profile
                      https://github.com/meltingmedia/Tools/blob/develop/core/components/tools/elements/snippets/hook.photo.php in french howto use http://toutsurmodx.fr/photo-profil-modx.html looks like it still needs a bit of work to be complete. mostly error checking and file type for security checks ect..

                      Since i'm wanting my users to have multiple images, i'm thinking i just have to have a different page just for photo's and users image gallery. and then just grab n display the photo in the view profile page.
                      http://rtfm.modx.com/display/ADDON/sekUserGalleries looks like this may work well for me. alot to this extra..

                      http://blueimp.github.com/jQuery-File-Upload/ also looks interesting. though same thing as fileupload just prettier and more features drag n drop is cool... but still then have to find a way to link the images to the user profile. perhaps using FileLister and configuring the output to whatever is wanted.

                      I'll post back with what i end up finding that works. if anyone else has any idea's let us know.