I build web application to manage spare parts for client,it comes with manual book as standard their part-id.
I checked its part-id are unique numbers. Storing records using MYSQL v5.5.16 and web interface using PHP v5.3.8.
As client requirement, they want to have spare parts image to be listed in folder. Basically, when user inputting record and upload a image, i renamed the image based on part-id stored into database and copied an uploaded image to folder.
Yes, it work well when user displaying images (part-id: 241203, 299301 ... etc). When part-id come with 1/8S40003, as you know image name couldn't consist with some characters (/ \ : * ? " < > |).
I also put <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
between <head>
tags and header('Content-type: text/html; charset=utf-8');
on the top of page.
I simplified, just encode '/' sign to html decimal code -> /
.
Storing image name into database seem work well, uploading image work 100%, i also checking image manually inside folder,
but when displaying image with
<img src='../Images/Spare parts/1/8S40003.png' />
Web browser automatically decoded it into path directory ('/'), but i checked a tag on 'view source', it written with <img src='../Images/Spare parts/1/8S40003.png' />
.
Even using htmlentities, html_entity_decode, htmlspecialchar, htmlspecialchars_decode doesn't work and make it worse to convert '&' sign into &
I found another way, by using urlencode from php, by convert '/' -> %2F and append the rest of number.
<img src='../Images/Spare parts/1%2F8S40003.png' />
I checked a tag on 'view source', it written similar with above but it doesn't give an solution.
Anyone, who ever had experienced with this problem before or ideas would be appreciated ! Thank you.