mcmuney Posted July 31, 2009 Share Posted July 31, 2009 I'm using a script to upload photos, during the upload it adds additional information to the original filename, for example: $_GET['file_name']=$time."_".$mem_id._.$_GET['file_name']; $rfn=$_SERVER['DOCUMENT_ROOT']."/images/".$_GET['file_name']; So, if the filename was abc.jpg, it will upload it as 1177799496_1_abc.jpg. PROBLEM: When there's a [] in the file name, like abc[1].jpg, having the [] causes a load issue. What can I add to remove the [] from the file during the rename process? Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/168242-solved-file-renamingextracting/ Share on other sites More sharing options...
Zyx Posted July 31, 2009 Share Posted July 31, 2009 Use strtr() function: echo strtr($filename, '[]', '__'); It will replace the square brackets with underscores. Quote Link to comment https://forums.phpfreaks.com/topic/168242-solved-file-renamingextracting/#findComment-887413 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.