We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30215
    • 79 Posts
    I’d like to allow users to upload files to the server and add some simple info to the uploaded files (title, description etc). Snippet or module, both would be possible. I couldn’t find anything suitable so far. I am using Evolution.
      -- sorry for my english, bad teacher smiley
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      That means either a database table or a file for storing the information. I use an AJAX file upload script for this kind of thing; I prefer Uploadify http://www.uploadify.com/
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 30215
        • 79 Posts
        I know I need an extra storage for the information. That’s the reason why I am asking for some existing solution. I don’t want to write it on my own smiley But I guess I have no choice smiley

        Thanks for the tip, Uploadify looks interesting.
          -- sorry for my english, bad teacher smiley
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          You might be able to use something like Jot with the uploadify script embedded in a customized Jot form tpl. Then you’d have everything all done for you; all you would need to do is have the AJAX processor to do the move_uploaded_file() thing. Jot would handle the file info for you, as well as displaying a list of files later if you wish. It’s very flexible.
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 30215
            • 79 Posts
            Wow, that’s an interesting idea! Actually, I don’t even need the uploadify plugin after all. I could just let the integrated file manager to the whole job and store just the path in Jot custom field. Of course, only the user with access to the manager could upload files but it’s exactly what I need. Thanks!
              -- sorry for my english, bad teacher smiley
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              I even have instructions for embedding the system’s MCPuck resource browser into Notes/Jot, it’s the same thing except you use a type of "files" instead of "images". Just change the "notes..." stuff to "jot...", and watch out for the paths in the OpenServerBrowser function. I didn’t suggest this before, as I wasn’t sure you wanted the user to be accessing all of the other files in the folder.
              #########################################
              # javascript for implementing resource browser for image 
              # upload/insertion in Jot/Notes forms.
              # The SetUrl function must have the id attribute of the input field 
              # to hold the image url.
              #########################################
              function OpenServerBrowser(url, width, height ) {
              	var iLeft = (screen.width  - width) / 2 ;
              	var iTop  = (screen.height - height) / 2 ;
              
              	var sOptions = 'toolbar=no,status=no,resizable=yes,dependent=yes' ;
              	sOptions += ',width=' + width ;
              	sOptions += ',height=' + height ;
              	sOptions += ',left=' + iLeft ;
              	sOptions += ',top=' + iTop ;
              
              	var oWindow = window.open( url, 'FCKBrowseWindow', sOptions ) ;
              }			
              function BrowseServer(notesId) {
                  window.notesId = notesId;
              	var w = screen.width * 0.7;
              	var h = screen.height * 0.7;
              	OpenServerBrowser('/manager/media/browser/mcpuk/browser.html?Type=images&Connector=/manager/media/browser/mcpuk/connectors/php/connector.php&ServerPath=/PATH/TO/public_html/assets/', w, h);
              }
              
              function SetUrl(url, width, height, alt){
              	document.getElementById('wtImage'+window.notesId).value = url;
              }
              
              #############################################
              # form field for uploading/inserting images in Jot/Notes form
              # id attributed of the input field must match the parameter of the 
              # getElementbyId function in the javascript.
              #############################################
              		<label for="wtImage[+notes.id+]">Image:<br />
              			<input tabindex="[+notes.seed:math=`?+6`+]" name="image" type="text" size="20" value="[+form.field.custom.image:esc+]" id="wtImage[+notes.id+]" /><input type="button" value="Select Image" onclick="BrowseServer('[+notes.id+]')" />
              		</label><br />
              
                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org
                • 30215
                • 79 Posts
                Sorry, I always forget to mention something important smiley

                Thanks for the script, helped a lot. I have now very functional upload manager based on Jot and it looks exactly like I wanted so I am really happy now smiley However I had a little fight with Jot as I don’t know Jot much, so it took a while to get it working. Maybe it would have been faster if I had created it completely myself but at least I learned something new.
                  -- sorry for my english, bad teacher smiley
                  • 16337
                  • 44 Posts
                  new kid on the block: http://www.plupload.com/

                  looks totally cool. should be easy to integrate with modx... any takers?