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.
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
|
show 6 more comments
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.
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
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
|
show 6 more comments
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.
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
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.
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
php codeigniter
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
|
show 6 more comments
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
|
show 6 more comments
1 Answer
1
active
oldest
votes
up vote
-1
down vote
try to use change $config
$config['remove_space'] = TRUE;
add a comment |
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;
add a comment |
up vote
-1
down vote
try to use change $config
$config['remove_space'] = TRUE;
add a comment |
up vote
-1
down vote
up vote
-1
down vote
try to use change $config
$config['remove_space'] = TRUE;
try to use change $config
$config['remove_space'] = TRUE;
answered yesterday
Ohansyah
46
46
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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