How do I check if a string has a \ in it?
Posted: Tue Jan 11, 2005 10:42 pm
Hi guys,
OK, I originally had a piece of code that checked if the value passed by a form field was nothing (ie, formfield = ""). This worked well until I found out just now that I had to include an enctype in my form so that the file upload would happen. A side effect of this is apparently that the empty file fields are no longer "". So if I don't have all of them filled, it overwrites what's in the database with an empty string. Since this is an edit form, I'd prefer not to have to tell them to re-enter files that they have already entered and which don't need to be changed.
So I figured that the best way to deal with this is to now check if the contents of the form field contain a "\" - there's guarenteed to be one of them in pretty much any file path as far as I've ever seen. Is this the best idea? If so, how do I do it? I can't find anything in the documentation to suggest that there is a "contains" function or something similar (ie, formfield contains "\").
Or can anyone suggest a better way to do this?
Cheers,
Seona.
OK, I originally had a piece of code that checked if the value passed by a form field was nothing (ie, formfield = ""). This worked well until I found out just now that I had to include an enctype in my form so that the file upload would happen. A side effect of this is apparently that the empty file fields are no longer "". So if I don't have all of them filled, it overwrites what's in the database with an empty string. Since this is an edit form, I'd prefer not to have to tell them to re-enter files that they have already entered and which don't need to be changed.
So I figured that the best way to deal with this is to now check if the contents of the form field contain a "\" - there's guarenteed to be one of them in pretty much any file path as far as I've ever seen. Is this the best idea? If so, how do I do it? I can't find anything in the documentation to suggest that there is a "contains" function or something similar (ie, formfield contains "\").
Or can anyone suggest a better way to do this?
Cheers,
Seona.