34 of 34
34
New Extension: nGen File Field for FieldFrame
Posted: 02 March 2010 10:21 PM   [ Ignore ]   [ # 595 ]  
Grad Student
Rank
Total Posts:  87
Joined  03-11-2007

Is there documentation somewhere about how to get this to work in an SAEF?  I can’t get it working.  The files upload fine, but if you go “edit” in the CP, the files don’t show up.  They’re physically on the server, in the right folder, and renamed if they had a duplicate name, but the custom field is empty.

Profile
 
 
Posted: 03 March 2010 03:01 AM   [ Ignore ]   [ # 596 ]  
Grad Student
Rank
Total Posts:  87
Joined  03-11-2007

OK, according to ngen, this is a known issue for v1.0.  So then, how the hell do I get v0.9.10???  All you can download is 1.0, but it doesn’t work with an SAEF.  Am I the only one that finds this kind of strange?  They broke a key component of the extension, then called it “1.0?”

Profile
 
 
Posted: 03 March 2010 03:03 AM   [ Ignore ]   [ # 597 ]  
Grad Student
Rank
Total Posts:  87
Joined  03-11-2007

Well, I got lucky and figured I’d try to just change the number in the zip file URL and it worked…

Changed:
http://www.ngenworks.com/software/ee/ngen-file-field/ngen-file-field-1.0.zip

To:
http://www.ngenworks.com/software/ee/ngen-file-field/ngen-file-field-0.9.10.zip

I guess for the time being, if you’re having SAEF issues, use the second link I just posted.

Profile
 
 
Posted: 03 March 2010 04:38 PM   [ Ignore ]   [ # 598 ]  
Grad Student
Rank
Total Posts:  87
Joined  03-11-2007

I’m not sure how many of you would want this, but I basically had to customize this extension for my needs.  I was originally trying to get some help from nGen, but they didn’t seem too interested in even talking to me and just told me to subit a feature request.  Needless to say, when you need something NOW, you don’t submit feature requests, you go make features yourself.

So, what I have working now is nGen file field creating unique sub-folders for each author.  So, if your author ID is say 123, instead of files being uploaded to images/uploads/, they get uploaded to images/uploads/123/.  This was critically important as the site I’m doing this for will have tens of thousands of “authors” (users) that each need to upload about 10 images.  Having all of the images all in one folder would be a bad idea, obviously, so I came up with this.  Now I just need to modify what I have a touch so instead of /123, it gets exploded and put together as /1/2/3.  With 10,000 users, having 10,000 folders in one place would almost be as bad as all of the images in one folder, so I think doing the sub folders for each digit will be the best way around that.

Anyway, if this is something you’re interested in, let me know and I’ll post the code.  I have it working with an SAEF and the CP.

Profile
 
 
Posted: 03 March 2010 05:07 PM   [ Ignore ]   [ # 599 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  566
Joined  12-08-2007
RealityDesign - 03 March 2010 09:38 PM

Anyway, if this is something you’re interested in, let me know and I’ll post the code.  I have it working with an SAEF and the CP.

Curious to see how you worked it out.

 Signature 

www.pixogee.com EE Pro Network

Profile
 
 
Posted: 03 March 2010 05:13 PM   [ Ignore ]   [ # 600 ]  
Grad Student
Rank
Total Posts:  87
Joined  03-11-2007

In the most simple terms, this is basically all I changed:

//
    // Retrieves the upload preferences for an upload location
    // returns upload_prefs array
    //
    
function _get_upload_prefs($u_id{
        
        
if( !isset($this->upload_prefs['loc_id']) || $this->upload_prefs['loc_id'!= $u_id {
            
global $DB$FNS$PREFS;
            
            
$query $DB->query("SELECT * FROM " $this->db_prefix "_upload_prefs WHERE id = $u_id");
            
            if (isset(
$_POST['author_id'])) {
                $author_id 
$_POST['author_id'];    
            
else if (isset($_GET['entry_id'])) {
                $entry_id 
$_GET['entry_id'];
                
$author_query $DB->query("SELECT * FROM " $this->db_prefix "_weblog_titles WHERE entry_id = $entry_id");
                
$author_id $author_query->row['author_id'];
            
else {
                $author_id 
"none";
            
}
            
            $this
->upload_prefs['loc_id'$u_id;
            
$this->upload_prefs['server_path'$query->row['server_path'$author_id "/";
            
$this->upload_prefs['server_uri'parse_url($query->row['url']PHP_URL_PATH) . $author_id "/";
            
//$upload_prefs['server_url'] = $FNS->remove_double_slashes( $PREFS->ini('site_url') . $upload_prefs['server_uri'] );
            
$this->upload_prefs['server_url'$query->row['url'$author_id "/";
            
$this->upload_prefs['allowed_types'$query->row['allowed_types'];
            
$this->upload_prefs['max_file_size'$query->row['max_size'];
        
}
            
        
//return $upload_prefs;
    

Now, there were some other minor issues, such as getting nGen to create new folders on publish, not just edit, and I fixed those as well.  For whatever reason, if a folder doesn’t exist when using the Edit CP, nGen makes a new folder you, but this function never gets executed from the publish CP.  Now I have that working on both.

If you want the whole file, just send me a PM.

Profile
 
 
Posted: 03 March 2010 06:09 PM   [ Ignore ]   [ # 601 ]  
Grad Student
Rank
Total Posts:  87
Joined  03-11-2007

I have the “exploded” version working now, where it makes sub-folders 6 digits deep.  So for example, a user ID of 123456 would have images located at: images/uploads/1/2/3/4/5/6/filename.jpg.  User ID 1 would be located at: images/uploads/0/0/0/0/0/1/filename.jpg.

This is the code:

//
    // Retrieves the upload preferences for an upload location
    // returns upload_prefs array
    //
    
function _get_upload_prefs($u_id{
        
        
if( !isset($this->upload_prefs['loc_id']) || $this->upload_prefs['loc_id'!= $u_id {
            
global $DB$FNS$PREFS;
            
            
$query $DB->query("SELECT * FROM " $this->db_prefix "_upload_prefs WHERE id = $u_id");
        
            if (isset(
$_POST['author_id'])) // if this is a new entry, get the author id from the hidden form field
                
$author_id $_POST['author_id'];    
            
else if (isset($_GET['entry_id'])) // if this is an existing entry, get the entry ID and find the author
                
$entry_id $_GET['entry_id'];
                
$author_query $DB->query("SELECT * FROM " $this->db_prefix "_weblog_titles WHERE entry_id = $entry_id");
                
$author_id $author_query->row['author_id'];
            
else // if all else fails, give it a 0 value so there aren't any "undefined" notices
                
$author_id "0";
            
}

            $auth 
$author_id ""// get the author id and convert it to a string
            
$length strlen($auth); // get the number of digits of the id
            
            
if ($length == 1{
                $author 
"0/0/0/0/0/" $auth[0] "/";
            
else if ($length == 2{
                $author 
"0/0/0/0/" $auth[0] "/" $auth[1] "/";    
            
else if ($length == 3{
                $author 
"0/0/0/" $auth[0] "/" $auth[1] "/" $auth[2] "/";    
            
else if ($length  == 4{
                $author 
"0/0/" $auth[0] "/" $auth[1] "/" $auth[2] "/" $auth[3] "/";    
            
else if ($length == 5{
                $author 
"0/" $auth[0] "/" $auth[1] "/" $auth[2] "/" $auth[3] "/" $auth[4] "/";    
            
else if ($length == 6{
                $author 
$auth[0] "/" $auth[1] "/" $auth[2] "/" $auth[3] "/" $auth[4] "/" $auth[5] "/";    
            
}
                    
            $this
->upload_prefs['loc_id'$u_id;
            
$this->upload_prefs['server_path'$query->row['server_path'$author;
            
$this->upload_prefs['server_uri'parse_url($query->row['url']PHP_URL_PATH) . $author;
            
//$upload_prefs['server_url'] = $FNS->remove_double_slashes( $PREFS->ini('site_url') . $upload_prefs['server_uri'] );
            
$this->upload_prefs['server_url'$query->row['url'$author;
            
$this->upload_prefs['allowed_types'$query->row['allowed_types'];
            
$this->upload_prefs['max_file_size'$query->row['max_size'];
        
}
            
        
//return $upload_prefs;
    
}
    
// 

Then all you have to do is find the two places with the “mkdir” function, and add “true” to the end of it to make the mkdir recursive.

Change:

$create_dir mkdir($path0777); 

To:

$create_dir mkdir($path0777true); 
Profile
 
 
Posted: 29 April 2010 01:07 PM   [ Ignore ]   [ # 602 ]  
Research Assistant
RankRankRank
Total Posts:  330
Joined  09-03-2008

Hey I’ve got the memory leak error as well:

Fatal errorOut of memory (allocated 63700992) (tried to allocate 26608 bytesin /home/ZZZ/public_html/manage/extensions/fieldtypes/ngen_file_field/ft.ngen_file_field.php on line 842 

but the file does not appear in FTP to delete, and increasing the max upload size did not help. What do I do to get rid of this error so I can make changes to my entries again?

Profile
 
 
Posted: 29 April 2010 01:27 PM   [ Ignore ]   [ # 603 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1174
Joined  02-14-2008

Increase the memory limit on your php config

 Signature 

Digital Evangelist | ghijk Ltd | Follow me on Twitter | Pro Network | EE UK Hosting

Profile
 
 
Posted: 29 April 2010 01:31 PM   [ Ignore ]   [ # 604 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  132
Joined  04-25-2009

I think the file has to be hiding somewhere where you could find and delete via FTP.  Doesn’t it?

Profile
 
 
Posted: 29 April 2010 01:55 PM   [ Ignore ]   [ # 605 ]  
Research Assistant
RankRankRank
Total Posts:  330
Joined  09-03-2008

yeah I already did increase memory limit in php.ini. Didn’t solve problem (and actually, the file upload that broke it was not over the limit). Also, I upgraded the plugin, and now no error displays, but any of the weblogs that use that field group display a white page if you attempt to edit them.

Profile
 
 
Posted: 17 May 2010 09:44 AM   [ Ignore ]   [ # 606 ]  
Summer Student
Total Posts:  2
Joined  07-22-2008

I’d like to use nGen and FF for an existing EE1 website, and i’m currently using the old File extension.  Is there any documentation or guidance that people could point me to for migrating from File to nGen easily?  I’ve got about 2,000 entries so really don’t want to do this manually!

Profile
 
 
Posted: 25 May 2010 01:56 PM   [ Ignore ]   [ # 607 ]  
Lab Assistant
RankRank
Total Posts:  286
Joined  02-25-2006

Hello I posted at the Ngen tech support area at http://help.ngenworks.com/discussions/ngen-file-tech/85-error-when-uploading

I am having trouble uploading mp3 when submitting. It says try again. Uploading PDFs are fine.

Any ideas?

Profile
 
 
Posted: 25 May 2010 02:14 PM   [ Ignore ]   [ # 608 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  575
Joined  03-18-2007

Try turning off the xss filter in security settings temporarily.

 Signature 

Follow me on Twitter: twitter.com/mrw

Note: I used to be slapshotw on this forum.

Profile
 
 
Posted: 25 May 2010 02:17 PM   [ Ignore ]   [ # 609 ]  
Lab Assistant
RankRank
Total Posts:  286
Joined  02-25-2006

You mean the “Apply XSS Filtering to uploaded files?” setting in Security and Session Preferences?

That was already on it seems.

Profile
 
 
Posted: 25 May 2010 02:18 PM   [ Ignore ]   [ # 610 ]  
Lab Assistant
RankRank
Total Posts:  286
Joined  02-25-2006

wait nevermind, you said off. smile let me turn it off.

Profile
 
 
Posted: 25 May 2010 02:19 PM   [ Ignore ]   [ # 611 ]  
Lab Assistant
RankRank
Total Posts:  286
Joined  02-25-2006

I get the same error on submission with XSS off.

Something happened while uploading 2010-04-30_BBC_Newshour.mp3 Please try again 
Profile
 
 
Posted: 25 May 2010 02:30 PM   [ Ignore ]   [ # 612 ]  
Lab Assistant
RankRank
Total Posts:  286
Joined  02-25-2006

I tried adding AddType audio/mpeg mp3 to the htaccess file but no go.

Profile
 
 
   
34 of 34
34