Appending Date/Time Stamp to filename
From: Don (no_at_adr.com)
Date: 09/26/04
- Next message: Stan Sainte-Rose: "Sun Java Plug-in Detection ?"
- Previous message: Marcin Ciemny: "Hot to show system resources on Active Desktop?"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 26 Sep 2004 07:05:55 -0700
Hi all,
With regards to the following, how do I append the datetimestamp to
the filenames in the form? The files are processed using the PHP
script that follows below.
Thanks in advance,
Don
Following running on client-side:
--------------------------------------
<html>
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head>
<body>
<script type="text/javascript">
function datetimestamp()
{
var today = new Date();
var sToday = (today.getMonth()+1).toString();
sToday += today.getDate().toString();
sToday += today.getYear().toString();
sToday += today.getHours().toString();
sToday += today.getMinutes().toString();
sToday += today.getSeconds().toString();
return sToday;
}
</script>
<form enctype="multipart/form-data" action="http://notRealURL.php"
method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="200000" />
<input type="hidden" name="MAX_INPUT_TIME" value="280" />
Send file 1: <input name="userfile[]" type="file" /><br />
Send file 2: <input name="userfile[]" type="file" /><br />
Send file 3: <input name="userfile[]" type="file" /><br />
Send file 4: <input name="userfile[]" type="file" /><br />
<input type="submit" value="Send File" />
</form>
</body>
Following server-side PHP script receives and uploads the files:
---------------------------------------------------------------------------
<?php
$uploaddir = 'picturevault/';
$uploadfile1 = $uploaddir . $_FILES['userfile']['name'][0];
$uploadfile2 = $uploaddir . $_FILES['userfile']['name'][1];
$uploadfile3 = $uploaddir . $_FILES['userfile']['name'][2];
$uploadfile4 = $uploaddir . $_FILES['userfile']['name'][3];
print "<pre>";
if ($_FILES['userfile']['size'][0] != 0) {
if (move_uploaded_file($_FILES['userfile']['tmp_name'][0],
$uploadfile1)) {
print "File is valid, and was successfully uploaded. ";
print "Here's some more debugging info:\n";
print_r($_FILES);
} else {
print "Possible file upload attack! Here's some debugging
info:\n";
print_r($_FILES);
}
print "</pre>";
}
if ($_FILES['userfile']['size'][1] != 0)
move_uploaded_file($_FILES['userfile']['tmp_name'][1],
$uploadfile2);
if ($_FILES['userfile']['size'][2] != 0)
move_uploaded_file($_FILES['userfile']['tmp_name'][2],
$uploadfile3);
if ($_FILES['userfile']['size'][3] != 0)
move_uploaded_file($_FILES['userfile']['tmp_name'][3],
$uploadfile4);
print "</pre>";
?>
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
- Next message: Stan Sainte-Rose: "Sun Java Plug-in Detection ?"
- Previous message: Marcin Ciemny: "Hot to show system resources on Active Desktop?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|