Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Bulk Uploader Module: Testers needed!


Go to End
Reply


57 Posts   13569 Views

Avatar
UncleCheese

Forum Moderator, 4096 Posts

9 January 2009 at 9:28am

Edited: 09/01/2009 10:20am

Documentation is here:
http://doc.silverstripe.com/doku.php?id=modules:bulkuploaderfield

Enjoy!

Edit: I guess the "remove attachment" feature doesn't work? Oy... Just use the last one.. 0.0.3.

Avatar
Amir Mostofi

Community Member, 59 Posts

9 January 2009 at 11:10am

Edited: 09/01/2009 11:10am

UncleCheese,

Thank you for the module. Here's how my test went.
I downloaded bulkuploader0.0.3.zip, unzipped the file and uploaded folders "bulk_uploader", "swfupload", and "sortable_dataobject" to the root of a fresh SS 2.3.0-rc2 install which only had the base e-commerce trunk module installed.

I wanted to implement the feature for the basic Page type, so below is my code for Page.php.

-----------------------
<?php

class Page extends SiteTree {
   
   public static $db = array(
   );
   
   public static $has_one = array(
   );
   
   static $has_many = array (
   'Resources' => 'Resource'
   );
   
   function getCMSFields()
   {
    $fields = parent::getCMSFields();
    $fields->addFieldToTab("Root.Content.Files", new BulkUploaderField(
   $this,
    'Resources',
   'PDF'
    ));
    return $fields;
   }

}

class Page_Controller extends ContentController {
   
   public function init() {
      parent::init();

      // Note: you should use <% require %> tags inside your templates instead of putting Requirements calls here. However
      // these are included so that our older themes still work
      Requirements::themedCSS("layout");
      Requirements::themedCSS("typography");
      Requirements::themedCSS("form");
   }
   
}

?>
-----------------------

and the following is the code for Resource.php

-----------------------
<?php

class Resource extends DataObject {
   static $db = array (
   'Name' => 'Text',
   'Description' => 'Text'
   );
   
   static $has_one = array (
   'Page' => 'Page',
   'PDF' => 'File'
   );
   
   protected static $bulk_uploader_fields = array (
   'Name' => 'TextField',
   'Description' => 'TextField'
   );
   
   protected static $allowed_file_types = array (
   'pdf'
   );

}

?>
-----------------------

I did a dev/build and ?flush=1 on the admin.

The build completes successfully and a "Files" tab is created for page type "Page" as expected. 2 points though:

1. In the "Manage Files" section on the right, you can import from an existing folder under assets, but that imports all the files in the selected folder. Ideally, you want to be able to choose the file(s) to import from a folder. Otherwise, you are forced to import all files from a folder first and then delete the ones you don't want from the left. This could be a very unnecessary and time consuming process, if for instance you had a subfolder "PDF" which contained say 100 uploaded PDF files, but you only needed one or two of them to be attached to a page.

2. The "Upload files" function on the left does not work at all. Initially, I get "There are currently no files attached to this page. Upload files" with an "UPLOAD FILES" button below. Whether I press the "Upload files" link or button below, the flash uploader does not load. I simply get an "Upload File(s)" button followed by "Allowed file types: pdf".

Thanks,
Amir

Avatar
UncleCheese

Forum Moderator, 4096 Posts

9 January 2009 at 11:23am

Selecting individual files is definitely coming. I just want to get a functional prototype out there right now. It's certainly not feature complete.

Not sure about the Flash uploader. I've tested it on several different computers and browsers and I haven't had a problem. Are you able to use the demo at this URL?

http://demo.swfupload.org/v220beta4/applicationdemo/index.php

What version of Flash player do you have? (If you know)

Avatar
Amir Mostofi

Community Member, 59 Posts

9 January 2009 at 1:13pm

There was no issue using the demo at http://demo.swfupload.org/v220beta4/applicationdemo/index.php.

I order to bring up the swfuploader in SS, I had to modify couple of the URL settings in "swfupload/_config.php".

The swfuploader comes up and allows me to select file(s) of types I specified (all the rest are greyed out). The file(s) get listed, but when I click on "Upload File(s)" I get a pop up error box saying "An error occurred in the upload. Try again later."

In "swfupload/_config.php", I see the following line:

'upload_url' => 'swfupload/code/SWFUploadHandler.php',

However, "swfupload/code/SWFUploadHandler.php" does not exist in the files provided.

I also see all these php.ini files in "swfupload/", "swfupload/code/", "swfupload/css/", "swfupload/images/" and "swfupload/javascript/" folders. Should these be there?

Also, what is the allowed file size limit?

Avatar
UncleCheese

Forum Moderator, 4096 Posts

9 January 2009 at 2:17pm

This line:

'upload_url' => 'swfupload/code/SWFUploadHandler.php',

doesn't matter because it is overridden in the BulkUploader_Controller when the SWFUploadField is instantiated. What did you modify to get it working? Was it the path to the SWF file, perhaps?

Please delete all those php.ini's.. That might have something to do with it. My hosting provider sucks!

Max upload size is set to whatever the php.ini max_upload_size is set to. Anything more would throw an error.

My guess is it's the php.ini files that are causing the problem. Also, could you please try changing flash_url variable to just 'swfupload.swf'? I'm wondering if we even need any pathing at all.

Also, to see what's going on behind the scenes, add this to the SWFUploadField in BulkUploader_Controller:

      $fields = new FieldSet(
         new SWFUploadField("UploadForm","","",array(
            'file_upload_limit' => '100', // how many files can be uploaded
            'file_queue_limit' => '100', // how many files can be in the queue at once
            'browse_button_text' => 'Choose files...',
            'upload_url' => '/'.$this->RelativeLink('handleswfupload'),
'debug' => 'true' // turns on debug mode
         ))

That will tell you what error is happening when Flash contacts the server. Let me know what it is.

Thanks for all your investigation. I love fixing bugs!

Avatar
Amir Mostofi

Community Member, 59 Posts

9 January 2009 at 4:21pm

I got rid of the php.ini files.
In "swfupload/_config.php", I modified the following urls:

'file_destination_path' => 'assets/Uploads/'
'flash_url' => 'swfupload/javascript/swfupload.swf'
'button_image_url' => 'swfupload/images/XPButtonNoText_160x22.png'

I did a dev/build and ?flush=1 and the swfuploaded still did not upload any files and came up with the same error box saying "An error occurred in the upload. Try again later."

'flash_url' and 'button_image_url' had to specified as above. I tried a few other urls, but either the swf file would not load at all or the button background image would not appear.

Then, I added the debug line to "BulkUploader_Controller.php" and when trying to upload a file selected, I get the following debug messages (note: I am only showing the debug messages for this step)

---------------
SWF DEBUG: StartUpload: First file in queue
SWF DEBUG: Event: uploadStart : File ID: SWFUpload_0_0
SWF DEBUG: Global Post Item: file_destination_path=assets/Uploads/
SWF DEBUG: ReturnUploadStart(): File accepted by startUpload event and readied for upload. Starting upload to /bulkuploader/handleswfupload/Page/Page/Resources/Resource/PDF/File/1 for File ID: SWFUpload_0_0
SWF DEBUG: Event: uploadProgress (OPEN): File ID: SWFUpload_0_0
SWF DEBUG: Event: uploadError: HTTP ERROR : File ID: SWFUpload_0_0. HTTP Status: 404.
SWF DEBUG: Event: uploadComplete : Upload cycle complete.
Error Code: -200, File name: webA_page_4.pdf, File size: 1375483, Message: 404
---------------

Avatar
Amir Mostofi

Community Member, 59 Posts

9 January 2009 at 4:25pm

Just in case, below is the entire output of the debug screen.

----------------
---SWFUpload Instance Info---
Version: 2.2.0 Alpha
Movie Name: SWFUpload_0
Settings:
   upload_url: /bulkuploader/handleswfupload/Page/Page/Resources/Resource/PDF/File/1
   flash_url: swfupload/javascript/swfupload.swf?swfuploadrnd=401381842
   use_query_string: false
   file_post_name: swfupload_file
   post_params: [object Object]
   file_types: *.pdf;
   file_types_description:
   file_size_limit: 32768
   file_upload_limit: 100
   file_queue_limit: 100
   debug: true
   prevent_swf_caching: true
   button_placeholder_id: spanButtonPlaceholder
   button_image_url: swfupload/images/XPButtonNoText_160x22.png
   button_width: 160
   button_height: 22
   button_text: <span class='button'>Choose files...</span>
   button_text_style: .button { font-family: Helvetica, Arial, sans-serif; font-size: 12px; }
   button_text_top_padding: 4
   button_text_left_padding: 5
   button_action: -110
   button_disabled: false
   custom_settings: [object Object]
Event Handlers:
   swfupload_loaded_handler assigned: true
   file_dialog_start_handler assigned: true
   file_queued_handler assigned: true
   file_queue_error_handler assigned: true
   upload_start_handler assigned: true
   upload_progress_handler assigned: true
   upload_error_handler assigned: true
   upload_success_handler assigned: true
   upload_complete_handler assigned: true
   debug_handler assigned: true

SWF DEBUG: SWFUpload Init Complete
SWF DEBUG:
SWF DEBUG: ----- SWF DEBUG OUTPUT ----
SWF DEBUG: Build Number: SWFUPLOAD 2.2.0 Alpha 2008-10-17
SWF DEBUG: movieName: SWFUpload_0
SWF DEBUG: Upload URL: /bulkuploader/handleswfupload/Page/Page/Resources/Resource/PDF/File/1
SWF DEBUG: File Types String: *.pdf;
SWF DEBUG: Parsed File Types: pdf,
SWF DEBUG: File Types Description: (*.pdf;)
SWF DEBUG: File Size Limit: 33554432 bytes
SWF DEBUG: File Upload Limit: 100
SWF DEBUG: File Queue Limit: 100
SWF DEBUG: Post Params:
SWF DEBUG: file_destination_path=assets/Uploads/
SWF DEBUG: ----- END SWF DEBUG OUTPUT ----
SWF DEBUG:
SWF DEBUG: Event: fileDialogStart : Browsing files. Multi Select. Allowed file types: *.pdf;
SWF DEBUG: Select Handler: Received the files selected from the dialog. Processing the file list...
SWF DEBUG: Event: fileQueued : File ID: SWFUpload_0_0
SWF DEBUG: Event: fileDialogComplete : Finished processing selected files. Files selected: 1. Files Queued: 1
SWF DEBUG: StartUpload: First file in queue
SWF DEBUG: Event: uploadStart : File ID: SWFUpload_0_0
SWF DEBUG: Global Post Item: file_destination_path=assets/Uploads/
SWF DEBUG: ReturnUploadStart(): File accepted by startUpload event and readied for upload. Starting upload to /bulkuploader/handleswfupload/Page/Page/Resources/Resource/PDF/File/1 for File ID: SWFUpload_0_0
SWF DEBUG: Event: uploadProgress (OPEN): File ID: SWFUpload_0_0
SWF DEBUG: Event: uploadError: HTTP ERROR : File ID: SWFUpload_0_0. HTTP Status: 404.
SWF DEBUG: Event: uploadComplete : Upload cycle complete.
Error Code: -200, File name: webA_page_4.pdf, File size: 1375483, Message: 404

----------------

Avatar
Amir Mostofi

Community Member, 59 Posts

9 January 2009 at 4:30pm

On another note, when do you think you might be able to complete the functionality to select individual files when importing from assets folder/subfolders?

Go to Top