[ic] how to remove path from file upload when updating database

Thanh Luong interchange-users@icdevgroup.org
Tue Nov 26 14:30:01 2002


--- Lyn St George <lyn@zolotek.net> wrote:
> On Tue, 26 Nov 2002 08:19:41 -0500, Mike Heins wrote:
> 
> >Quoting Lyn St George (lyn@zolotek.net):
> >> On Mon, 25 Nov 2002 11:07:47 -0800 (PST), Thanh Luong wrote:
> >> 
> >> >I have a form which adds new data to a table every
> >> >time it is submitted.  On the form there are some
> >> ><input type=file ...> everytime the "Browse" button is
> >> >clicked the name reads C:\somedir\somefile.jpg and
> >> >thus the database table records
> >> >C:\somedir\somefile.jpg. I would like the database to
> >> >record only the last portion, somefile.jpg and have
> >> >the path removed.
> >> 
> >> As you're using this on Windows, therein  lies your problem. This
> kind 
> >> of thing works flawlessly on Unix (Linux, *BSD, Solaris, even on
> OS/2 ...) 
> >> but on Windows all bets are off. You'll find this comment in the
> faq:
> >> " ... there are numerous anomalies and it may be difficult to get
> [IC on Windows] 
> >> operating reliably". Sorry, but that's it. 
> >> 
> > Mike Heins wrote:
> >It should work fine on the client side. It begs the question of the
> browser
> >in use, though. I happen to know this type of thing works fine on
> MSIE
> >5 and above....
> 
> Resending, as I've just got back that infamous "Your message to 
> interchange-users awaits moderator approval" It may be real, as there
> 
> was an attachment, but ...
> 
> ====================
> 
> Thinking about it a little more (through the worst head-cold in
> history) I 
> would hazard a guess that the real culprit is your Windows
> implementation 
> of tar, in conjunction with the attached user-tag. This tag is
> designed to package 
> up any (uncounted) number of these images into a tarball for Stefan
> Hornburg's
> email-mime tag to email to the site owner. As all I know about
> windows is that 
> they break easily, I'll need to bow out of this thread and leave it
> to others to fix
> the code as appropriate for the environment ...
> 
> Tag included here (remember KISS .., and it requires "AllowGlobal")
> ==============
 

IC was installed via rpm installation on Red Hat 7.3 Linux server.

I am uploading the pictures for MSIE 5.5 and 6.0 and same thing
happens. The database records the entire path as well as the file name.
 Well maybe there is a way to strip out the path before IC records it
to the database.

Here are the hidden variables and the import parts of the code
<FORM ACTION="[process-target secure=1]" METHOD="POST"
ENCTYPE="multipart/form-data">
<INPUT TYPE=hidden NAME=mv_session_id VALUE="[data session id]">
<INPUT TYPE=hidden NAME=mv_click VALUE="update_database"> 
<INPUT TYPE=hidden NAME=mv_todo VALUE="set"> 
<INPUT TYPE=hidden NAME=mv_nextpage VALUE="output">
<INPUT TYPE=HIDDEN NAME=mv_data_table VALUE="car_of_the_week_db">
<INPUT TYPE=HIDDEN NAME=mv_data_function VALUE="insert">
<INPUT TYPE=HIDDEN NAME=mv_data_key VALUE="code">
<input type=hidden name=mv_data_fields value="code,....">
<input type=hidden name=code value="NULL">
<input type=hidden name="mv_action" value=return>

<input type=text .....>
<input type=file name=img_general value="[value
img_general]">
etc...
----------------------------------
I used the following code on my output page to strip the path from the
file name before it is saved to the my pix/ directory.
[if value img_general]
	[set name=upload_filename interpolate=1][calc]
	$filename = "";
	$filename = $CGI->{img_general};
	$filename =~ s|.*[\\/]||;
	return $filename;
	[/calc][/set]
	[scratch upload_filename]=[value-extended Yes=Yes
No=No name=img_general
	 umask=022
	    outfile="pix/[scratch upload_filename]"]
[/if]

Thanks for all your help guys.

Tom

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com