Jump to content

Vinlock

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Vinlock's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. 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.'; } } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.