7954 Posts in 1394 Topics by 945 members
|Go to End||Next >|
29 June 2009 at 11:08pm
My productionserver can't handle GD-imageresizing on large images (it's giving an error, and the only way to solve things is to delete the file manually through directAdmin, which is giving problems with the ImageGallery-db).
To overcome this problem, I would like to limit the maximum filesize for images uploaded with ImageGallery (or SWFUpload).
Is this possible and how?
BTW I found this line in the _config.php of SWFUpload:
'file_size_limit' => str_replace("M","MB",ini_get('upload_max_filesize')),
But changing it to for example str_replace("k","kB","500k") will affect all filetypes, and I would like to be able to upload some PDF's and mp3's that are bigger.
30 June 2009 at 1:39am
Just add in your _config.php:
30 June 2009 at 1:56am Last edited: 30 June 2009 1:59am
But... that's also a general rule, isn't it?
At least: adding it to image_gallery/_config.php didn't work
And in swfpload/_config.php the value appears to be used for all filetypes (also PDF and MP3 etc), so I guess it's just another way to say 'file_size_limit' => str_replace("k","kB","500k"),?
What I'm looking for is something to limit the filesize for specific filetypes, just like in FileField (line 24):
public $allowedMaxFileSize = array('*' => 3000000, 'jpg' => 400000, 'jpeg' => 400000, 'gif' => 400000, 'png' => 400000);
30 June 2009 at 2:10am
Unfortunately that's beyond the capabilities of the SWFUpload right now. That would require expanding the Flash component itself, which is something I know nothing about, but you can put in a request at swfupload.org.
The only solution that would come close to that is if you added the file_size_limit setting conditionally based on, say, the current controller, but that would be a catch-all solution for all files uploaded to that controller, not a per-file interrogation.
30 June 2009 at 2:47am
I already was afraid that it was beyond the capabilities of SWFUpload.
Do you think it is possible to extend the SWFUpload module and reset the strict upload-limit?
In that way it would be possible to use SWFUpload for images and SWFUploadExtended for all other files.
30 June 2009 at 3:20am
Well, again.. If the controller dictates the file types that are to be expected, then you can work around that.
if(Controller::curr()->class == "ImageGalleryManager") // could be wrong on that.. i'm not sure what the controller is of the popup window.
30 June 2009 at 12:50pm
I've been trying something like this for some time now. Let me give you all an update:
1st: I guess SWFUploadConfig::set_var('file_size_limit', '10M'); should be in swfupload/_config.php, if it's placed in mysite/_config.php the upload uses the default file_size_limit that is set through line 10 of swfupload/_config.php.
2nd: It seems image-gallery has no active current controller (as the notification-message I got already indicated). Testing it with if(Controller::has_curr() == true) echo 'test'; doesn't echo anything, while if(Controller::has_curr() == false) echo 'test'; does... On the other hand, even Page.php doesn't seem to have an active current controller.
So... after all I'm ending up with the same situation (that's a bit too static for me).
I'm thinking about either extracting the file-extension of the uploaded file end using it in an if-statement (which seems to be tricky to setup, but very dynamical) or getting the classname of the pagetype and relate to that in the if-statement.
Maybe there is someone who has another idea?
Or the night will help my mysterious windows-machine to understand everything I feed it - that would be nice ;-)
1 July 2009 at 6:18am
Interesting.. Well this raises a few issues. First, I always thought the mysite/_config.php was executed last, in order to give the user absolute override power. Turns out it runs first, which is pretty lousy. You should never have to modify the _config file of a module. When you upgrade, you'll lose your changes. What a pain. That's what the mysite/_config.php should be used for, but unfortunately, it's getting trumped by the module in this case.
Also, at the time of execution for _config.php, no controller has been loaded, so you're not able to sniff it out there. Annoying!
I wonder if there are any other hooks we can use to set that variable. I'll keep thinking about it some more..
|Go to Top||Next >|