MySQL interesse |
|
Boys,
Deze code:
// make a note of the current working directory, relative to root.
$directory_self = str_replace(basename($_SERVER['PHP_SELF']), '', $_SERVER['PHP_SELF']);
// make a note of the directory that will recieve the uploaded file
$uploadsDirectory = $_SERVER['DOCUMENT_ROOT'] . $directory_self . 'uploaded_images/';
// fieldname used within the file <input> of the HTML form
$fieldname = 'img';
@getimagesize($_FILES[$fieldname]['tmp_name']);
// make a unique filename for the uploaded file and check it is not already
// taken... if it is already taken keep trying until we find a vacant one
// sample filename: 1140732936-filename.jpg
$now = time();
while(file_exists($uploadFilename = $uploadsDirectory.$now.'-'.$_FILES[$fieldname]['name']))
{
$now++;
}
// now let's move the file to its final location and allocate the new filename to it
@move_uploaded_file($_FILES[$fieldname]['tmp_name'], $uploadFilename);
// make a note of the current working directory, relative to root. // make a note of the directory that will recieve the uploaded file $uploadsDirectory = $_SERVER['DOCUMENT_ROOT'] . $directory_self . 'uploaded_images/'; // fieldname used within the file <input> of the HTML form $fieldname = 'img'; // make a unique filename for the uploaded file and check it is not already // taken... if it is already taken keep trying until we find a vacant one // sample filename: 1140732936-filename.jpg while(file_exists($uploadFilename = $uploadsDirectory.$now.'-'.$_FILES[$fieldname]['name'])) { $now++; } // now let's move the file to its final location and allocate the new filename to it
(Ja, via tut)
Ik wil graag alleen de filename opslaan, dus niet het hele pad erbij. Hoe kom ik daarbij?
|