CodeIgniter Forums
Upload Class orig_name - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Upload Class orig_name (/showthread.php?tid=22785)



Upload Class orig_name - El Forum - 09-20-2009

[eluser]CoffeeBeanDesign[/eluser]
Hi there,

Glad to see file_name added to the latest version of the Upload Class however it seems to mess up the orig_name variable. If you set a file_name the orig_name is changed too.

Line 245 :
Code:
$this->orig_name = $this->file_name;

I think it should come earlier, before the name has been changed :

Somewhere like line 190 :

Code:
// Set the uploaded data as class variables
$this->file_temp = $_FILES[$field]['tmp_name'];    
$this->orig_name =$_FILES[$field]['name'];    
$this->file_name = $this->_prep_filename($_FILES[$field]['name']);

I'm not 100% sure of the logic of why the orig_name is set afterwards, there may be a perfectly good reason, perhaps I just can't see it yet...


Upload Class orig_name - El Forum - 02-19-2010

[eluser]hotmeteor[/eluser]
Ya, this is a bug. I've reproduced it while doing a multi-file upload loop.

Basically, all of the filedata is reset in the loop for the new file, EXCEPT for orig_name. But adjusting the code as stated above it fixes it. Not sure why though.