Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Sep 2011
    Posts
    69
    Thanks
    6
    Thanked 0 Times in 0 Posts

    remove space from during uploading files

    Hi,

    I am uploading files into directory and store file name in mysql database

    for selecting file for uploading having spaces like (abc def.jpg)

    I need to remove space and save into directory and also in mysql database like (abcdef.jpg)

    I used str_replace but I failed to achieve my need

    Please help me about it

    regards

  • #2
    Senior Coder
    Join Date
    Jul 2011
    Posts
    1,226
    Thanks
    3
    Thanked 171 Times in 171 Posts
    str_replace is the function you want. How were you using it?
    Useful function to retrieve difference in times
    The best PHP resource
    A good PHP FAQ
    PLEASE remember to wrap your code in [PHP] tags.
    PHP Code:
    // Replace this
    if(isset($_POST['submitButton']))
    // With this
    if(!empty($_POST))
    // Then check for values/forms. Some IE versions don't send the submit button 
    Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.

  • #3
    New Coder
    Join Date
    Sep 2011
    Posts
    69
    Thanks
    6
    Thanked 0 Times in 0 Posts
    sorry you didn't understood my requirement

    for example I am uploading a file with name which is showing space (abc def.jpg)

    during uploading I need to remove the space from file name like this (abcdef.jpg)

  • #4
    Senior Coder
    Join Date
    Jul 2011
    Posts
    1,226
    Thanks
    3
    Thanked 171 Times in 171 Posts
    Quote Originally Posted by shajiuddin View Post
    sorry you didn't understood my requirement

    for example I am uploading a file with name which is showing space (abc def.jpg)

    during uploading I need to remove the space from file name like this (abcdef.jpg)
    I understood your requirement perfectly. $_FILES['input']['name'] will equal 'abc def.jpg' in your example. So, you should do this:
    PHP Code:
    $name str_replace(' ','',$_FILES['input']['name']); 
    Useful function to retrieve difference in times
    The best PHP resource
    A good PHP FAQ
    PLEASE remember to wrap your code in [PHP] tags.
    PHP Code:
    // Replace this
    if(isset($_POST['submitButton']))
    // With this
    if(!empty($_POST))
    // Then check for values/forms. Some IE versions don't send the submit button 
    Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.

  • Users who have thanked BluePanther for this post:

    shajiuddin (01-10-2012)


  •  

    Posting Permissions

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