Re: Reg Exp to change c:\dir\dir\pic.jpg to dir/pic.jpg - to upload image path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



ioannes wrote:
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.

Maybe it's just early, and I haven't had my caffeine yet - but it seems to me something fairly basic is being overlooked...


a web browser doesn't even give you this information!

if you really need it, for whatever reason, you're going to have to pull the information out of the file input through javascript. IIRC you can read from a file input, but I know for a fact you can't change it (at least, not without perhaps an exploit or some horrible activex why_would_this_ever_be_enabled_microsoft_you_fools() function calls.)

You're better off providing keywords, categories, folders or labels to go along with the images for your users, instead of trying to match their organization with yours.

Cheers,
--
- Martin Norland, Database / Web Developer, International Outreach x3257
The opinion(s) contained within this email do not necessarily represent those of St. Jude Children's Research Hospital.


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux