Could someone please help me with the code below, I want the file that is being uploaded to be renamed with a random number in addition to the unix timestamp to prevent a filename from ever being duplicated.
I also want to check that files being uploaded are .jpg, .jpeg, .gif, or .png
I've been trying for ages done a lot of googling but can't seem to get it to work for me.
Code:echo 'Upload result:<br>'; $uploaddir = dirname($_SERVER['SCRIPT_FILENAME'])."/UploadedFiles/"; $target_encoding = "ISO-8859-1"; echo '<pre>'; if(count($_FILES) > 0) { $arrfile = pos($_FILES); $uploadfile = $uploaddir . iconv("UTF-8", $target_encoding,basename($arrfile['name'])); if (move_uploaded_file($arrfile['tmp_name'], $uploadfile)) echo "File is valid, and was successfully uploaded.\n"; } else echo 'No files sent. Script is OK!'; echo 'Here is some more debugging info:'; print_r($_FILES); echo "</pre>"; ?>



Reply With Quote

Bookmarks