Mark Huot - File - Multiple image upload error
Posted: 27 November 2008 05:47 AM   [ Ignore ]  
Lab Assistant
RankRank
Total Posts:  148
Joined  03-05-2008

I am running and loving this extension, especially combined with imgsizer…
However, i have come across a problem that i am yet to find a solution to and wonder if anyone else has seen, or been able to resolve it…

I have setup “file” to allow multiple uploads of images. The idea being each article permits multiple images to be uploaded when they save the article. When i browse and select one image, click quick save, then select another, quick save, etc, etc… The plugin works fine and displays each image in its own row.
However, when i browse and select multiple images and click save to save a batch of say 3 in one go… The last image appears to overwrite the previous two, and i end up with three rows, all with the same file name, thumbnail and image.

Now this is likely to be a loop error somewhere, but i have been struggling to find it. I managed to find the count error and solve that with forums support. But any tips here would be gratefully received.
Thanks, N

 Signature 

Stock Photo & Vectors - Free Stock Photos - Free Stock Vectors

Profile
 
 
Posted: 27 November 2008 06:37 AM   [ Ignore ]   [ # 1 ]  
Lab Assistant
RankRank
Total Posts:  148
Joined  03-05-2008

okay. after a bit of digging i am coming to the conclusion (might be wrong) that when you select an image the plugin automatically adds a new file field. However, seeing as this file field has exactly the same name as the one above it, that is what is causing the problem… this is dropping well outside of my experience, so any advice appreciated on how to resolve.

 Signature 

Stock Photo & Vectors - Free Stock Photos - Free Stock Vectors

Profile
 
 
Posted: 27 November 2008 06:55 AM   [ Ignore ]   [ # 2 ]  
Lab Assistant
RankRank
Total Posts:  148
Joined  03-05-2008

okay… my first diagnosis was incorrect!!! Typical!!!
The problem is that Mark Huot’s file uses a MD5 of the unix time stamp to create a unique file name. When you upload multiple files, it happens so quickly it uses the same time stamp and therefore file name for all multiple image uploads. The end result being that it overwrites all previous upload with the last file… Really simple fix… When the foreach loop runs to generate the unique file name add the loop key to the ed of the unique file name, and it worked! woo hoo… code below:

Around line 759 (note this might be off as i have another fix in place for the count problem).

//  =============================================
//  Rewrite (or Code) File Names?
//  =============================================
if($this->rewrite_filenames === TRUE)
{
    
foreach($file_names as $file_key=>$file_name)
    
{
        $file
= $this->_pieces($file_name);
        
//$file_names[$file_key] = $this->_code().$file['ext'];
        
$file_names[$file_key] = $this->_code().$file_key.$file['ext'];
    
}
}

note the line changed has been //out and the new line is beneath it…
So now fixed is the count issue and multiple file upload issue - should we be supplying these updates to mark huot to make a new release? Is he available anymore?

 Signature 

Stock Photo & Vectors - Free Stock Photos - Free Stock Vectors

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 66389 Total Logged-in Users: 50
Total Topics: 84714 Total Anonymous Users: 18
Total Replies: 454689 Total Guests: 191
Total Posts: 539403    
Members ( View Memberlist )