472,950 Members | 2,334 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,950 software developers and data experts.

tricky php, can anyone help

I'm a bit stuck! Please can someone help.

Here's what I'm trying to build:

1. Webform which puts variables into a database (each with unique ID
field)
2. Webform also allows attachment which uploads the file to specific
directory
3. On submission of webform for a file on the directory to be
duplicated and renamed "unique ID".php and placed in a specific folder
I have completed 1 + 2, but am stuck with the 3rd.

A few of my thoughts on this are:

Regarding the creation/duplication and renaming of the .php file,
maybe I can treat this as a file upload but from the server - a little
confusing, but I'm thinking along the lines of how the file upload
works above, except this would be a hidden field in the submission
form, and I'd have to set the path to the file on the server in the
hidden field also - not sure how to do this though...

....Plus this also leaves the problem of giving the duplicated file
it's related "uniqueid.php" name.

The contents of the php file that I'm wanting to create/duplicate will
all be the same code each time the form is submitted. I will have code
in these files which reads the file name and displays the proper stuff
related to the file name.

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.

If anyone can help me with any bitesize portion of this I'd appreciate
it.

Thanks for any help
Jan 16 '08 #1
4 1438
Hi there,

ma*****@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
Jan 16 '08 #2

"C. (http://symcbean.blogspot.com/)" <co************@gmail.comschreef in
bericht
news:95**********************************@u10g2000 prn.googlegroups.com...
>try the example onhttp://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";}

?>

no - use move_uploaded_file() instead - RTFM

C.
it was the manual i quoted......
OP was using copy() and was wondering why it did not work,
not questioning himself if there was another (or better) option.

;-)

Jan 16 '08 #3

<ma*****@gmail.comschreef in bericht
news:16**********************************@e23g2000 prf.googlegroups.com...
On Jan 16, 8:26 am, "C. (http://symcbean.blogspot.com/)"
>>
no - use move_uploaded_file() instead - RTFM

C.


If there's a way for this to work then I just need to figure out how
to copy a file already on the server to a new location and rename
(I'll check your suggestion Luuk)

Thanks
copy and rename can be done in 1 step, as C suggested

http://nl2.php.net/move_uploaded_file

Jan 16 '08 #4
Thanks Guys I have it all working perfectly it seems!

Thanks again for your help very useful.
M
Jan 16 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Bung | last post by:
Hi, I have a tricky sql statment I have to write (tricky for me) and I am stuck. I'm having trouble with the following problem. Table1 (Column a, Column b, Column c) Table2 (Column a, Column...
2
by: M Maloney | last post by:
Hey all, I was wondering if anyone could help me with this problem I have: Given a text file like this: 8 =ABC 18.00 Dr Who: Underworld 18.30 Collectors 19.00 News
25
by: PyPK | last post by:
What possible tricky areas/questions could be asked in Python based Technical Interviews?
5
by: Danny | last post by:
Hi there I need help with a tricky problem. I have a 2 dimensional array with qualities such as ball size, ball color, ball weight. Now I have to print out all the possible combinations of...
8
by: pras.vaidya | last post by:
Hi , below given question was asked to me during an interview and i figured it out little tricky . It would be a great help if anyone could solve it. Code : - main() { char...
3
by: knocte | last post by:
I am using the XmlDocument class to generate a XML document "on the fly", I mean, build it in memory so as to extract its contents with the property "OuterXml". I know how to create elements and...
1
by: MorrganMail | last post by:
Or at least I find it tricky. :-) Assume we have three tables A, B and C. Table A contains a path and the distance for traveling that path: A (PathId, NodeId, Dist (from previous node)) 1, 1,...
2
by: fleece | last post by:
Hi, I need help on this tricky access permission issue: For my database, I want to allow users be able to edit his/her records, insert new ones and review other user's records but no edit. How to...
11
by: seberino | last post by:
How extract the visible numerical data from this Microsoft financial web site? http://tinyurl.com/yw2w4h If you simply download the HTML file you'll see the data is *not* embedded in it but...
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.