You are here: Re: tricky php, can anyone help « PHP Programming Language « IT news, forums, messages
Re: tricky php, can anyone help

Posted by matpac4 on 11/13/57 12:00

On Jan 16, 2:59 am, Marlin Forbes <"marlinf <AT> datashaman <POINT>
wrote:
> Hi there,
>
> matp...@gmail.com 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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация