Forums

PHP

This topic is locked

Can't Insert Variable !

Posted 16 Aug 2002 19:23:15
1
has voted
16 Aug 2002 19:23:15 Peter R posted:
I have a photo upload script and I'm trying to give the photos a unique(but meaningful) name.

This line in the script right now names the uploaded file. It takes the photos original name, and adds the time in front of it:

$file_name = time()."$image_name";
... produces 1029342277_Elexa.jpg

But in the form that submits the photo to be uploaded, I've added a hidded field "idnum" which contains a unique id for the picture which corresponds to it's place in the database. Let's say the value submitted by "idnum" is "27_6_".

I would like this variable to be put infront of $image_name instead of the time to produce an image name like:

27_6_Elexa.jpg

But no matter how I arrage the line of code, I still can't get the $idnum to appear within the name.

I've tried changing the line to:

$file_name = $HTTP_POST_VARS['idnum'] . "$image_name";
... with no success.

Is there some special way I have to call $idnum into the script before I can use it?

Thank you for any help, I've included the whole script here:
www.shopstrathroy.com/uploadresizecode.htm
...just incase. <b><font color=red>Three areas which I believe to be important are highlighted in RED.</font id=red></b>

Thanks again!

Peter

Replies

Replied 16 Aug 2002 22:14:16
16 Aug 2002 22:14:16 Peter R replied:
Problem solved!

The trick was to put:

global $HTTP_POST_VARS;

...just before...

$file_name = $HTTP_POST_VARS['idnum'] . "$image_name";


Thanks for reading!

Peter
Replied 18 Aug 2002 15:23:23
18 Aug 2002 15:23:23 Tim Green replied:
If you are using a more recent version of PHP (ie: PHP 4.2.x) you don't need to worry about the global statement. Just use $_POST instead of $HTTP_POST_VARS, as this variable is automatically global anyway.

hth

Tim Green

Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>

Reply to this topic