Re: tricky php, can anyone help



On Jan 16, 2:59 am, Marlin Forbes <"marlinf <AT> datashaman <POINT>
wrote:
Hi there,

matp...@xxxxxxxxx wrote:
But I need a way of getting the unique id to the file name and am not
sure of a way to do this, especially with the problem of when several
people are completing the form at the same time. I need to make sure
that the number given to the duplicated .php file isn't associated
more than once.

When handling uploaded files in PHP, the $_FILES array holds a variable:

$_FILES['userfile']['tmp_name']

The tmp_name is guaranteed to be unique within the folder where the
temporary uploaded files are stored. You could strip the filename
portion of that out and use it in your destination folder.

For more details on file uploads and the temp folder handling, see the
entry under Features/Handling file uploads in the manual.

Or alternately, you can use the php function tempname, detailed under
Filesystem Functions in the manual.

Regards,
Marlin Forbes
Data Shaman
datashaman.com

I'm not sure that this would solve the problems either, because I'd
like to try and control to some extent the unique ID's. In the same
way that when the form is submitted, the values enter the db and each
row is given a unique ID, I need the attachment (which I currently
have being uploaded with its name) to have its name changed to the
unique ID and the other action i needed was for a php file on the
server to be duplicated into a folder and be renamed "unique ID".php

The name of the image I'm uploading needs to have the same name as the
php file.

This process of uploading the attachment, duplicating/copying and
renaming the php file on server and entering the table contents into
the DB could happen thousands of times - I would ideally like the
names of the php pages to be 1001.php, 1002.php, 1003.php etc. (and
the associated attachment uploads to be 1001.gif, 1002.gif, 1003.gif

These dont necessarily need to be the same as the unique number thats
given to the mysql contents - but I'll have to do something to be able
to reference the db contents with the file names later (maybe add this
info to an extra table)....

do you have any ideas on how to make the names sequential like this
yet only allocate them once so that there's no problems with more than
one person filling in the form at any 1 time.


Do you have any experience with this code for duplicating a file on
the server, I cant get it to work:

$source_file = 'dir/folder/template.php';
$dest_file = 'dir/newfolder/newname.php';

copy($source_file, $dest_file);

You can see how I'm trying to copy this folder over and rename it.
Eventually I'd like to substitute 'newname.php' with '$uniqueID.php'

But if you can help me with the baby steps of getting any file to copy
and rename it'd really help.

Thx
.



Relevant Pages

  • Re: tricky php, can anyone help
    ... that the number given to the duplicated .php file isn't associated ... The tmp_name is guaranteed to be unique within the folder where the ... For more details on file uploads and the temp folder handling, ... This process of uploading the attachment, duplicating/copying and ...
    (comp.lang.php)
  • Re: tricky php, can anyone help
    ... entry under Features/Handling file uploads in the manual. ... renaming the php file on server and entering the table contents into ... You're going to let people upload php code to your server! ... it and rename it on form submit. ...
    (comp.lang.php)
  • Re: Junk messages comimg via my website form Please help
    ... the htaccess file can password protect a folder but I can foresee several problems. ... When Pub uploads files, it normally does so to the root directory, which would be fine. ... That folder would probably have to have a subfolder, /index_files, where Pub stores all the images and other pages, unless the user wanted only a text file. ...
    (microsoft.public.publisher)
  • Re: The rmo-associated upload groups
    ... played in sequence without having to go back to the computer each time and ... First create a new folder on your harddrive in a place that you can ... recognizable tune) when you are doing and listening to these uploads. ...
    (rec.music.opera)
  • Oooops! Re: The rmo-associated upload groups
    ... First create a new folder on your harddrive in a place that you can ... sub-folders and dragging Files to them and arranging their sequence for ... but one thing that would make the listening to me of the ... learning that for these small uploads, ...
    (rec.music.opera)