That's exactly what I want to do but I can't get the code to do it.

I'd much rather have an ID assigned to the file name and handle it
like that.

I just can't get it to work.  This project is going on 5 months over
due now.

Ugh.

--- In php-list@yahoogroups.com, "Marc Boncz" <[EMAIL PROTECTED]> wrote:
> Hi Marian,
> 
> > I'm still stuck here, and my clients are repeatedly breaking my system
> > by uploading files with spaces even though I keep telling them DON'T
> > DO THAT.
> >
> > Help?
> Don't use the name of a file the way a client has given it. simply
don't.
> You can never be sure if your client will stick to basic rules of
filenaming
> and still then, the client may just ask an uninstructed person
working for
> him/her to "please, upload that new picture when I'm away" and that
person
> may violate rules.
> Imagine that they use the same filename twice, the old one might be
> overwritten.
> Uploading systems have to be foolproof and the first thing is to not
allow
> users to do any nming themselves.
> 
> I always use a filename derived from the name of the table and the
primary
> key of that table (assuming you use a database to keep track of some
> characteristics of the file like a short description, date of creation,
> price of the shown article or whatever)
> 
> So say there is an upload form with fields for an image and a
caption to be
> displayed next to the image (also useful for the ALT tag).
> Then, after submitting:
> 1. check the file (see if it is a genuine JPG and not a
> virus/executable/watever)
> 2. store the data associated to the file like its caption
> 3. using the function mysql_insert_id() you will have the primary
key value
> of the record containing the image data.
> 4. move the image to its permanent location naming it.
> In my case for a client named 'Johnson' using a picture table named
> joPictures and a primary key joPi_PK the filename would be something
like
> joPi_PK-45.jpg. This allows me also to find back in a directory with
masses
> of image files to which table/record the pic belongs. In this case
record #
> 45 of the joPictures table.
> 5. store the name in the table ("update joPictures set
> joPi_filename='joPi_PK-45.jpg' where joPi_PK='45'")
> 6. ready.
> 
> Also prevents mountains of obsolete images when the client decides
to change
> an image for an already existing record, uploading a new image with a
> different name.
> 
> Marc




------------------------ Yahoo! Groups Sponsor --------------------~--> 
<font face=arial size=-1><a 
href="http://us.ard.yahoo.com/SIG=12h60dds4/M=362335.6886445.7839731.1510227/D=groups/S=1705005703:TM/Y=YAHOO/EXP=1124382042/A=2894361/R=0/SIG=13jmebhbo/*http://www.networkforgood.org/topics/education/digitaldivide/?source=YAHOO&cmpgn=GRP&RTP=http://groups.yahoo.com/";>In
 low income neighborhoods, 84% do not own computers. At Network for Good, help 
bridge the Digital Divide!</a>.</font>
--------------------------------------------------------------------~-> 

Community email addresses:
  Post message: php-list@yahoogroups.com
  Subscribe:    [EMAIL PROTECTED]
  Unsubscribe:  [EMAIL PROTECTED]
  List owner:   [EMAIL PROTECTED]

Shortcut URL to this page:
  http://groups.yahoo.com/group/php-list 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-list/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to