removing spaces from filenames before saving to directory

Last post 11-16-2009, 10:20 PM by cutechat. 1 replies.
Sort Posts: Previous Next
  •  11-13-2009, 2:53 PM 57143

    removing spaces from filenames before saving to directory

    Hi There,
     
    Does anybody know if it is possible (& easy) to remove/replace spaces from files that are uploaded before they are stored to the savefiles directory? I need this to be the case for my application.
     
    I've had a quick look at the php code, but because I'm new php, i thought i'd ask here first before trying to delve into it myself.
     
    Regards,
    Jim
  •  11-16-2009, 10:20 PM 57202 in reply to 57143

    Re: removing spaces from filenames before saving to directory

    Jim
     
    Hi, when the file have been uploaded , you can rename the file .
     
    In the examples , you can find the comments where you can handle the logic.
     
    For example , in example form-singlefile.php ,
     
    you can move the file by this way :
     
    if($mvcfile)
    {
       $newfilename=$mvcfile->FileName;
       $newfilename=preg_replace("/\\s/","",$newfilename);
       $mvcfile->MoveTo("/uploads/$newfilename");
    }
     
    Regards,
    Terry
     
View as RSS news feed in XML