Support » Fixing WordPress » WordPress media upload is in-compatible with Windows operating system?

  • Hi All,
    I am using WordPress for making website and i feel that it’s really simple and easy CMS for any non technical person. Most important thing is that, it is Open Source so i would like to have everybody’s attention towards my new issue which i faced while “Migrating site from LAMP(Linux Apache MySql PHP) platform to WIMP(Windows Internet-Information-Service MySql PHP) Platform”. My site contained images content for each post as an attachment. I had uploaded many more images with same name but with different case e.g. “Butter-scotch.png” and “Butter-Scotch.png” inside WordPress media and that was successfully uploaded and working to site on LAMP platform. WordPress “media upload” moving both images on Linux OS with same filename “Butter-scotch.png” and “Butter-Scotch.png” inside Upload directory. The uploaded images are treated as different on LINUX due to case sensitive file system feature of LINUX?. When i am moving whole working running site from LAMP platform to WIMP(Windos IIS MySQl PHP) platform at that time file get “over write” which were downloaded from current LAMP platform, when i am attempting to upload same files on WIMP because of cases are ignored on Windows?? Because file system of Windows is case in-sensitive and due to which “Butter-scotch.png” and “Butter-Scotch.png” are treated as same on WINDOWS. All this causing lot’s of image loss???? I don’t understand why WordPress core is using same name of image after moving it into media files UPLOAD directory directory instead of renaming with proper unique time stamp or crypt check sum?? e.g abcd.jpg with 1234567890.jpg like timestamp or like?? I am thinking the changes can be possible in function name “wp_handle_upload()” which is located inside “wp-admin/includes/file.php” on line no 445 of WordPress core??? But still i am looking for proper guidance if any one had faced same issue before??????

    I hope everyone understood my issue.

    Thanks & Regards

Viewing 1 replies (of 1 total)
  • Hi Omprakash,

    You don’t have to modify core code. Use following code in functions.php of your theme. It will rename the meida files as per your requirements.

    /*Code to rename media files in wordpress*/
    function custom_upload_name($filename){
    $info = pathinfo($filename);
    $ext = empty($info[‘extension’]) ? ” : ‘.’ . $info[‘extension’];
    $filename = time().’.’ . $info[‘extension’];
    return $filename;

    add_filter(‘sanitize_file_name’, ‘custom_upload_name’, 10);

    /*Its simple*/


Viewing 1 replies (of 1 total)
  • The topic ‘WordPress media upload is in-compatible with Windows operating system?’ is closed to new replies.