Re: tricky php, can anyone help




<matpac4@xxxxxxxxx> schreef in bericht
news:d3dba30e-9464-4818-af9a-9732133bf4c7@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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

try the example on http://nl3.php.net/manual/en/function.copy.php
<?php
$file = 'example.txt';
$newfile = 'example.txt.bak';

if (!copy($file, $newfile)) {
echo "failed to copy $file...\n";
}
?>

probably you get the result "failed to copy $file...\n"
because your webserver has nog enough rights...


.



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: Cannot find page- cgiemail
    ... needs to be mailer.php in the action for form properties NOT /cgi-bin/cgimail ... "Jana" wrote in message ... was i supposed to reference the php file in publisher somehow? ... The "mailer.php" and the "thank_you.htm" MUST be in the same folder as the ...
    (microsoft.public.publisher.webdesign)
  • Re: Replace and inserting strings within .txt files with the use of regex
    ... this number to store to the beginnign to the file as comment line, ... The page_id will, of course, be a string. ... decided to open the same php file for writing that data and then ... Well those lines are supposed to print current working folder and ...
    (comp.lang.python)
  • 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)