We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

File

Development and Programming

Mark Huot's avatar
Mark Huot
587 posts
about 18 years ago
Mark Huot's avatar Mark Huot

Hum. now what would {cover[1]} or {cover[2]} be used for. is cover 1 the src and cover 2 is the mouse over? or is cover 1 the source of one image and cover 2 is the source of the other?

       
ms's avatar
ms
274 posts
about 18 years ago
ms's avatar ms

Sorry, Mark … seems I’m not good at explaining today. We’re at 30+ degrees C and no A/C…

In the first example, both covermouseout and covermouseover are uploaded images (in separate fields), one picture per field. In the second example, they are just uploaded one after another in the (multifile-enables) field {cover}: two (or more) pics in one field. So, {cover[1]} would be the first image uploaded, {cover[2]} the second, and so on. My example was really stripped down because I’d like to have that extended to {cover[n]}, n=>1, being the nth uploaded file (or empty if less files were uploaded in that field.

Makes that any sense?

       
Mark Huot's avatar
Mark Huot
587 posts
about 18 years ago
Mark Huot's avatar Mark Huot

I guess what I’m confused about is if you use the multi enabled version people couldn’t people upload too many or too few images. meaning someone may not know to upload both a src image and a hover image. I would probably suggest the split out version, even if it is another field.

that said, i’m not really sure if there’s any current way to get at what you need. I guess you’d have to do it with PHP:

<?php
global $DB;
$row = $DB->query('SELECT field_id_XXX FROM exp_weblog_data WHERE entry_id="{entry_id}"');
$field_data = preg_split("/[\r\n]+/", $row['field_id_XXX']);
function element($ary,$key) { echo isset($ary[$key]) ? $ary[$key] : ''; }
?>

<?php element($field_data, 0); ?>

That’s off the top of my head and should work assuming there aren’t any typo’s or other silliness going on in there.

       
ms's avatar
ms
274 posts
about 18 years ago
ms's avatar ms

Thanks a lot, Mark.

I’ll digg into this. Right now, I’m already using multiple upload fields. But perhaps the PHP code might come in handy for a special scenario I’m working on.

       
Mark Huot's avatar
Mark Huot
587 posts
about 18 years ago
Mark Huot's avatar Mark Huot

I hope it does, let me know what you find out.

       
darylh's avatar
darylh
26 posts
17 years ago
darylh's avatar darylh

File extension calls the database 252 times in a single page!

The database is abused in this plugin. The db is queried even when you are accessing a MEMBER VARIABLE of the file class.

I slightly modified the code to hold the previous results in a static class variable. The fetch_setting() method first checks the class variable before turning to the database. The modification brought the total number of queries down to 4 (from 250+).

...
    var $docs_url        = 'http://docs.markhuot.com';
    
    //drch edit
    public static $uploadSettings;
    //end drch 

    //
    //constructor
    ...
function fetch_setting( $upload_id, $setting )
    {
        global $DB, $PREFS;
/* drch edit */
        if (!isset(self::$uploadSettings[$upload_id])) { 
            $upload_pref = $DB->query("SELECT * FROM exp_upload_prefs WHERE id='".$upload_id."'");
            self::$uploadSettings[$upload_id] = $upload_pref->row;
        }
        $row = self::$uploadSettings[$upload_id];
        if(isset($row['properties']) && $row['properties'] != "") parse_str($row['properties']);
        
        $val = isset($row[$setting]) ? $row[$setting] : (isset($$setting) ? $$setting : (isset($this->settings[$setting]) ? $this->settings[$setting] : ""));
/*end drch edit */

        if($val == "")
        {
            switch($setting)
            {
                case "url":
                    $val = preg_replace("/\/$/", "", $PREFS->core_ini['site_url'])."/images/uploads/";
                    break;
                case "server_path":
                    $val = preg_replace("/\/$/", "", PATH).'/../images/uploads/';
                    break;
                case "store_thumbs_separately":
                    $val = 'no';
                    break;
                case "thumb_width":
                    $val = '200';
                    break;
                case "thumb_height":
                    $val = '200';
                    break;
                case "allow_multiple":
                    $val = 'no';
                    break;
                case "show_preview":
                    $val = 'no';
                    break;
            }
        }
        if($val == 'yes') $val = true;
        else if($val == 'no') $val = false;
        
        return $val;
    }
       
Mark Huot's avatar
Mark Huot
587 posts
17 years ago
Mark Huot's avatar Mark Huot

thanks for that darylh. i’ve updated a few of my other extensions to fix this exact problem, but must have missed this one. what version are you using?

       
darylh's avatar
darylh
26 posts
17 years ago
darylh's avatar darylh

v.2.1.0

I downloaded it last week on 12-June.

       
Mark Huot's avatar
Mark Huot
587 posts
17 years ago
Mark Huot's avatar Mark Huot

thanks!

       
davenport's avatar
davenport
67 posts
17 years ago
davenport's avatar davenport

The extension works when I use small images and documents, but I need to upload a large 10mb audio file. It takes about 5 minutes for the file to upload, then the publish page just disappears and does not direct to the preview as it normally does.

Any clue what might be causing this?

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
17 years ago
Mark Bowen's avatar Mark Bowen

Hi davenport,

Sorry for butting in on the end of this thread like this and so I haven’t been following this fully but are you by any chance using Safari?

If so, have you turned off the cache in Safari?

This would have been done using a fairly techy tool such as MacPilot or Cocktail as I don’t think there is an easy way to do if from the actual Safari preferences pane.

If you re-enable the cache then all should be fine. Safari uses the cache as a temporary storage place for file uploads and so if this it disabled all will go to pot!!

If you aren’t on Safari then I apologize for butting in like this but just thought that this might help. It still might help others who are having problems though so hopefully helpful somewhere.

If you have never used either MacPilot or Cocktail then it may have been an extension or something else that would have caused this problem.

If you aren’t using Safari then maybe the cache in Windows works the same way? I’m not sure about that though as I haven’t ever touched a PC so wouldn’t know but may be something worth looking into?

Hope this helps yourself or others out there.

Best wishes,

Mark

       
Mark Huot's avatar
Mark Huot
587 posts
17 years ago
Mark Huot's avatar Mark Huot

@davenport - this could be a problem with your PHP or Apache configuration. Can you try uploading the same file through the built in EE interface. Does it work? Also, try somewhat smaller files? 9MB, 8MB, 7MB, 6MB. Where does it cut off?

There are a bunch of factors limiting large uploads on the web. First PHP has a limit for uploaded file sizes, then it’s got a limit on POST data size, both of those will have to be raised above their typical size of 2MB. And then of course there’s PHP memory limit, which will probably have to be raised also. Whenever I have a client uploading files larger than ~2M I usually have them us a FTP client, and then just have them insert the file name into a text field. That way they get a nice progress indicator and everything is a lot more stable.

       
Richard Frank's avatar
Richard Frank
200 posts
17 years ago
Richard Frank's avatar Richard Frank

Hi

I installed this extension and it allows me to upload PHP files, which is a security risk. My normal upload prevents this.

Any thoughts?

       
stinhambo's avatar
stinhambo
1,268 posts
17 years ago
stinhambo's avatar stinhambo

A hcrap, I’m getting an error when uploading on a local server (wasn’t a problem with 1.5.2 on the same server).

The error I am getting is -

Warning: move_uploaded_file(C:/dev/manag/admin/C:/dev/manag/images/uploads/hambo.jpg) [function.move-uploaded-file]: failed to open stream: Invalid argument in C:\dev\manag\admin\extensions\ext.file.php on line 552

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move ‘C:\Program Files\xampp\tmp\php26C.tmp’ to ‘C:/dev/manag/admin/C:/dev/manag/images/uploads/hambo.jpg’ in C:\dev\manag\admin\extensions\ext.file.php on line 552

       
Silencio's avatar
Silencio
46 posts
17 years ago
Silencio's avatar Silencio

I would like to know what files I’d need to change if I wanted to have the control panel part of this extension execute a custom script on uploading of images.

I’d also like to change the file paths, unique folder for each article entry group, and change the image names based on the date and categories.

Thanks.

** If what is above is possible… I’d like to then add a sorting option so the image order can be sorted. Then I’d also like to be able to crop and rotate images. Add captions and titles. Add a zip uploader feature so the images can be uploaded and processed by a client in bulk without ftp.

*** I’m really not impressed by the EE image gallery. It’s doesn’t work well for the clients I’ve had. It makes the most sense to me to have the gallery attached to the Articles, then you could have a seperate gallery weblog for a specific gallery.

       
First 11 12 13 14 15 Last

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.