Codeigniter image name with space upload issue











up vote
0
down vote

favorite












I have this weird issue about uploading images with name that has space in it.



On normal cases, uploading images goes through the function and there you can somehow remove the space or allow space or do whatever you want.



But in this case, it doesn't. It goes 404 page not found but not on the BASEPATH, it goes 404 on the main directory.
So I have 2 installations of CI (/admin and frontend in public_html) where /admin directory is inside the frontend.



enter image description here



Whenever I try to upload an image with name that has spaces, it somehow goes to frontend routes and looks for the /_admin page which is obviously not there thus goes to my custom 404 page.



Any idea on why is this happening?










share|improve this question






















  • To temporarily fix my issue, I removed the spaces on my images since it's only a few, lucky me. But I might need a permanent fix for this. JavaScript solution should be my last resort.
    – ACD
    yesterday










  • save the file name in DB, and rename the actual file when uploading. When you want to show the file name, get it from DB
    – Abdulla Nilam
    yesterday










  • why would you ever want to store files with spaces???
    – Alex
    yesterday










  • @AbdullaNilam it would be so easy to do that but the thing is, it doesn't go through the function where it supposed to go. Supposed it should go to /_admin/products/insert but the function is now 404 when carrying that $_FILE with spaced name image.
    – ACD
    yesterday










  • The above comment should be the way to go, in my perspective. But if you REALLY want to keep your files with a nice name, you must create a function to 'slugify' it; remove unwanted spaces, accented characters and probably any dots in the middle of the filename except, of course, the one that introduces its extension. Then you have to validate if the result filename already exists in the server or not. Note: you can start with some javascript function of course, but you'll need to use PHP nevertheless...
    – Pedro Serpa
    yesterday















up vote
0
down vote

favorite












I have this weird issue about uploading images with name that has space in it.



On normal cases, uploading images goes through the function and there you can somehow remove the space or allow space or do whatever you want.



But in this case, it doesn't. It goes 404 page not found but not on the BASEPATH, it goes 404 on the main directory.
So I have 2 installations of CI (/admin and frontend in public_html) where /admin directory is inside the frontend.



enter image description here



Whenever I try to upload an image with name that has spaces, it somehow goes to frontend routes and looks for the /_admin page which is obviously not there thus goes to my custom 404 page.



Any idea on why is this happening?










share|improve this question






















  • To temporarily fix my issue, I removed the spaces on my images since it's only a few, lucky me. But I might need a permanent fix for this. JavaScript solution should be my last resort.
    – ACD
    yesterday










  • save the file name in DB, and rename the actual file when uploading. When you want to show the file name, get it from DB
    – Abdulla Nilam
    yesterday










  • why would you ever want to store files with spaces???
    – Alex
    yesterday










  • @AbdullaNilam it would be so easy to do that but the thing is, it doesn't go through the function where it supposed to go. Supposed it should go to /_admin/products/insert but the function is now 404 when carrying that $_FILE with spaced name image.
    – ACD
    yesterday










  • The above comment should be the way to go, in my perspective. But if you REALLY want to keep your files with a nice name, you must create a function to 'slugify' it; remove unwanted spaces, accented characters and probably any dots in the middle of the filename except, of course, the one that introduces its extension. Then you have to validate if the result filename already exists in the server or not. Note: you can start with some javascript function of course, but you'll need to use PHP nevertheless...
    – Pedro Serpa
    yesterday













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I have this weird issue about uploading images with name that has space in it.



On normal cases, uploading images goes through the function and there you can somehow remove the space or allow space or do whatever you want.



But in this case, it doesn't. It goes 404 page not found but not on the BASEPATH, it goes 404 on the main directory.
So I have 2 installations of CI (/admin and frontend in public_html) where /admin directory is inside the frontend.



enter image description here



Whenever I try to upload an image with name that has spaces, it somehow goes to frontend routes and looks for the /_admin page which is obviously not there thus goes to my custom 404 page.



Any idea on why is this happening?










share|improve this question













I have this weird issue about uploading images with name that has space in it.



On normal cases, uploading images goes through the function and there you can somehow remove the space or allow space or do whatever you want.



But in this case, it doesn't. It goes 404 page not found but not on the BASEPATH, it goes 404 on the main directory.
So I have 2 installations of CI (/admin and frontend in public_html) where /admin directory is inside the frontend.



enter image description here



Whenever I try to upload an image with name that has spaces, it somehow goes to frontend routes and looks for the /_admin page which is obviously not there thus goes to my custom 404 page.



Any idea on why is this happening?







php codeigniter






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked yesterday









ACD

28110




28110












  • To temporarily fix my issue, I removed the spaces on my images since it's only a few, lucky me. But I might need a permanent fix for this. JavaScript solution should be my last resort.
    – ACD
    yesterday










  • save the file name in DB, and rename the actual file when uploading. When you want to show the file name, get it from DB
    – Abdulla Nilam
    yesterday










  • why would you ever want to store files with spaces???
    – Alex
    yesterday










  • @AbdullaNilam it would be so easy to do that but the thing is, it doesn't go through the function where it supposed to go. Supposed it should go to /_admin/products/insert but the function is now 404 when carrying that $_FILE with spaced name image.
    – ACD
    yesterday










  • The above comment should be the way to go, in my perspective. But if you REALLY want to keep your files with a nice name, you must create a function to 'slugify' it; remove unwanted spaces, accented characters and probably any dots in the middle of the filename except, of course, the one that introduces its extension. Then you have to validate if the result filename already exists in the server or not. Note: you can start with some javascript function of course, but you'll need to use PHP nevertheless...
    – Pedro Serpa
    yesterday


















  • To temporarily fix my issue, I removed the spaces on my images since it's only a few, lucky me. But I might need a permanent fix for this. JavaScript solution should be my last resort.
    – ACD
    yesterday










  • save the file name in DB, and rename the actual file when uploading. When you want to show the file name, get it from DB
    – Abdulla Nilam
    yesterday










  • why would you ever want to store files with spaces???
    – Alex
    yesterday










  • @AbdullaNilam it would be so easy to do that but the thing is, it doesn't go through the function where it supposed to go. Supposed it should go to /_admin/products/insert but the function is now 404 when carrying that $_FILE with spaced name image.
    – ACD
    yesterday










  • The above comment should be the way to go, in my perspective. But if you REALLY want to keep your files with a nice name, you must create a function to 'slugify' it; remove unwanted spaces, accented characters and probably any dots in the middle of the filename except, of course, the one that introduces its extension. Then you have to validate if the result filename already exists in the server or not. Note: you can start with some javascript function of course, but you'll need to use PHP nevertheless...
    – Pedro Serpa
    yesterday
















To temporarily fix my issue, I removed the spaces on my images since it's only a few, lucky me. But I might need a permanent fix for this. JavaScript solution should be my last resort.
– ACD
yesterday




To temporarily fix my issue, I removed the spaces on my images since it's only a few, lucky me. But I might need a permanent fix for this. JavaScript solution should be my last resort.
– ACD
yesterday












save the file name in DB, and rename the actual file when uploading. When you want to show the file name, get it from DB
– Abdulla Nilam
yesterday




save the file name in DB, and rename the actual file when uploading. When you want to show the file name, get it from DB
– Abdulla Nilam
yesterday












why would you ever want to store files with spaces???
– Alex
yesterday




why would you ever want to store files with spaces???
– Alex
yesterday












@AbdullaNilam it would be so easy to do that but the thing is, it doesn't go through the function where it supposed to go. Supposed it should go to /_admin/products/insert but the function is now 404 when carrying that $_FILE with spaced name image.
– ACD
yesterday




@AbdullaNilam it would be so easy to do that but the thing is, it doesn't go through the function where it supposed to go. Supposed it should go to /_admin/products/insert but the function is now 404 when carrying that $_FILE with spaced name image.
– ACD
yesterday












The above comment should be the way to go, in my perspective. But if you REALLY want to keep your files with a nice name, you must create a function to 'slugify' it; remove unwanted spaces, accented characters and probably any dots in the middle of the filename except, of course, the one that introduces its extension. Then you have to validate if the result filename already exists in the server or not. Note: you can start with some javascript function of course, but you'll need to use PHP nevertheless...
– Pedro Serpa
yesterday




The above comment should be the way to go, in my perspective. But if you REALLY want to keep your files with a nice name, you must create a function to 'slugify' it; remove unwanted spaces, accented characters and probably any dots in the middle of the filename except, of course, the one that introduces its extension. Then you have to validate if the result filename already exists in the server or not. Note: you can start with some javascript function of course, but you'll need to use PHP nevertheless...
– Pedro Serpa
yesterday












1 Answer
1






active

oldest

votes

















up vote
-1
down vote













try to use change $config



$config['remove_space'] = TRUE;






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53203642%2fcodeigniter-image-name-with-space-upload-issue%23new-answer', 'question_page');
    }
    );

    Post as a guest
































    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    -1
    down vote













    try to use change $config



    $config['remove_space'] = TRUE;






    share|improve this answer

























      up vote
      -1
      down vote













      try to use change $config



      $config['remove_space'] = TRUE;






      share|improve this answer























        up vote
        -1
        down vote










        up vote
        -1
        down vote









        try to use change $config



        $config['remove_space'] = TRUE;






        share|improve this answer












        try to use change $config



        $config['remove_space'] = TRUE;







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered yesterday









        Ohansyah

        46




        46






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53203642%2fcodeigniter-image-name-with-space-upload-issue%23new-answer', 'question_page');
            }
            );

            Post as a guest




















































































            Popular posts from this blog

            Schultheiß

            Verwaltungsgliederung Dänemarks

            Liste der Kulturdenkmale in Wilsdruff