Reg Exp to change c:\dir\dir\pic.jpg to dir/pic.jpg - to upload image path
| From: | ioannes | Date: | Wed, 09 Feb 2005 19:14:14 +0000 |
| Subject: | Reg Exp to change c:\dir\dir\pic.jpg to dir/pic.jpg - to upload image path | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-38533@lists.php.net to get a copy of this message | ||
I am trying to upload images - in fact an image path - from a PC.
I use the <input > tag:
<INPUT NAME="addpic" TYPE="file">
which nicely gives an input textfield and Browse button! This gives me, in the input box, eg:
c:\pics\subdir\pic1.jpg
The relative path on the server is something like:
subdir/pics1.jpg
thus I need to transform the string:
c:\subdir\pics\pics1.jpg
into:
pics/pics1.jpg
I can use str_replace() to change "\" into "/". I am looking for an expression
from some clever person to get rid of "c:\subdir\" given that I don't know the exact
'subdir' or name of the image.
Regards,
John