Changing name of the uploaded file. - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: Changing name of the uploaded file. (/showthread.php?tid=40814) |
Changing name of the uploaded file. - El Forum - 04-19-2011 [eluser]DADE[/eluser] Hello everyone, I got simple form: Code: <? Than I check for the spaces in the "artist" and "title" fields, and replace them with "_" symbol. Code: $artist = trim($this->input->post('artist')); Here's the result I get: P.S: For example lets say we've entered "P.O.D" as "artist" and "Boom" as "title" Code: echo $fulltitle // Gives me: P.O.D-Boom.mp3 But: Code: $config = array( Returns file named: Code: P.O_.D-Boom_.mp3 Thank you. P.S: CI 2.0.2 ADDED: Even If I'll do this: Code: $test = $this->input->post('test'); // Test = a.s.d.f. I don't understard why this underscores appears... Changing name of the uploaded file. - El Forum - 04-20-2011 [eluser]DADE[/eluser] Really no ideas? :/ Changing name of the uploaded file. - El Forum - 04-20-2011 [eluser]DADE[/eluser] Well, I found solution. system/libraries/Upload.php file, _prep_filename() function, line 994 Code: protected function _prep_filename($filename) Changing name of the uploaded file. - El Forum - 04-20-2011 [eluser]ecitron[/eluser] Typically, PHP does not alter the names of variables when they are passed into a script. However, it should be noted that the dot (period, full stop) is not a valid character in a PHP variable name. For the reason, look at it: <?php $varname.ext; /* invalid variable name */ ?> Now, what the parser sees is a variable named $varname, followed by the string concatenation operator, followed by the barestring (i.e. unquoted string which doesn't match any known key or reserved words) 'ext'. Obviously, this doesn't have the intended result. For this reason, it is important to note that PHP will automatically replace any dots in incoming variable names with underscores. Try this: Code: <?php http://lists.openidenabled.com/pipermail/dev/2007-March/000395.html OR Code: <?php Or use a str replace after passing the data again... I think that you're stuck with doing the job twice. Post the final result if you manage to get it work. EDIT: Nice |