SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2011
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    I need to capitalize my file extensions at upload

    I've followed the tutorial at http://net.tutsplus.com/tutorials/ph...-manipulation/ , and it has worked wonderfully. Unfortunately I am uploading to a file structure that is case sensitive. So I need to add a conversion (strtoupper) so image.jpeg automagically translates to image.JPG. any suggestions?

  2. #2
    SitePoint Mentor silver trophy
    Rubble's Avatar
    Join Date
    Dec 2005
    Location
    Cambridge, England
    Posts
    2,435
    Mentioned
    82 Post(s)
    Tagged
    3 Thread(s)
    Changing jpeg to JPG is not just capitalisation so strtoupper will not work.

    So what you want to do is change the extension in a file upload form?

    I can not be bothered to watch the tutorial - what code do you have?

  3. #3
    SitePoint Member
    Join Date
    Dec 2012
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You need to strip the extension with something like this:
    $strip = explode(".", $fileName); // Split file name into an array using the dot
    $fileExt = end($strip); // Now target the last array element to get the file extension

    Then use strtoupper like:

    $fileExt = strtoupper($fileExt);

    In theory this would work though I haven't tried it.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •