Vinlock
-
Posts
2 -
Joined
-
Last visited
Never
Posts posted by Vinlock
-
-
Hello,
I've looked everywhere for help, is there any chance anyone here that knows of PHP can help me out?
I have this snippet of code for uploading files. I really want it to rename the files with a date and/or time or anything random at the end of the image's name as it uploads. Would be an amazing help!! Thanks!
Here is the code.
<?php // Set the uplaod directory $uploadDir = '/images/'; if (!empty($_FILES)) { $tempFile = $_FILES['Filedata']['tmp_name'][0]; $uploadDir = $_SERVER['DOCUMENT_ROOT'] . $uploadDir; $targetFile = $uploadDir . $_FILES['Filedata']['name'][0]; // Validate the file type $fileTypes = array('jpg'); // Allowed file extensions $fileParts = pathinfo($_FILES['Filedata']['name'][0]); // Validate the filetype if (in_array($fileParts['extension'], $fileTypes)) { // Save the file move_uploaded_file($tempFile,$targetFile); echo 1; } else { // The file type wasn't allowed echo 'Invalid file type.'; } } ?>
Trying to get this PHP upload code to rename the file.
in PHP Coding Help
Posted
there is no $targetdir o.O