PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Hey guys quick question, does anyone know a method to maintain the image name while uploading? When I say that, I mean I am uploading images to a folder and storing url in database, and it seems the only way that most images will only be linked properly if I use rawurlencode() and that destroys the name integrity. urlencode() isn't as bad but does not work on all images for example this one for some reason 'DMX - It's Dark And Hell Is Hot'.
This is my script when the file is done checking and ready to upload
Could you maybe be more specific lol? I am still quite new to programming. I currently use sessions for login purposes but I do no know how that will help me maintain the image title.
lol why did you edit it? Anyway I downloaded your file, and I appreciate the tutorial, funnily enough it did help me feel more comfortable with sessions but it didn't really address my problem. I am talking about uploading an image or mp3 title into my database, and when I encode it, the title is changed beyond recognition from added characters, so I was wondering if there was an alternative, or function that would make the file url compatible, but readable by the original title.
I'm not so sure on that sorry mate. Only thing I DO know is, it has something to do w/ how the password system works. It's the same idea. It goes in as a password hash, and comes out as a decryption when u login to a site I would start there!
Yeah I just used preg_replace lol, I feel kind of dumb now for posting this now, but I hadn't used that function before, thanks mellow, and thanks shadow for your session tutorial, it did help me in a different way but I think you may be over using sessions lol. This is the code I used to accomplish this
Why not store the intact filename in the database? Format it with mysql_real_escape_string() to make it safe to use in the insert query. When you retrieve it from the database, URL-encode it if you need to use it in a hyperlink.
Edit: This post was recovered from search engine cache.
Last edited by McInfo on Thu Jun 17, 2010 4:17 pm, edited 1 time in total.
thats a good point, for some reason I was having trouble with some image names and urlencode, but I was using it before database instead of that preg statement. Probably just an error on my part. Great idea and Thanks for reminding me, I can't believe I actually forgot the escape statement.