Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Upload Script based on timestamp

Status
Not open for further replies.

twantrd

Technical User
Feb 13, 2005
26
0
0
US
Hi there,

I'm trying to setup a php script for users to be able to upload. I got the upload piece working but what's killing me is the directory timestamp. So, the scenario is that when a user uploads a file, the script will place that file on a directory based on the current date. Creating the directory based on the date is easy as I can write something in perl and put that in cron.

My variable in upload.php is this:
$file_dir = "/home/httpd-2.2.3/htdocs/"date("m.d.y");

I've seen other examples where people hard-code the path but I can't in this situation. Any advice? Is this even possible in php? Thank you.

-twantrd
 
If you don't hard-code at least the part of the path leading up to the daily directory, how will you set it?


Shouldn't your line of code read:

$file_dir = "/home/httpd-2.2.3/htdocs/" . date("m.d.y");

?



Want the best answers? Ask the best questions! TANSTAAFL!
 
You can also use the [blue]mkdir()[/blue] function to create the directory from withing PHP
using the timestamp.




----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Thanks guys! I got the answer. My variable needed to be set like so:

$upload_dir = "/home/httpd-2.2.3/htdocs/".date("m.d.y")."/";

-twantrd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top