Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $myFile = "log.txt";
- $target_path = "images/".$_POST['folder']."/";
- $target_path2 = $target_path . basename( $_FILES['uploadedfile']['name']);
- //var_dump(file_exists($_FILES['uploadfieldname']['tmp_name']));
- if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path2)) {
- $dir = opendir($target_path);
- $x = 1;
- $extension = substr($_FILES['uploadedfile']['name'], -4);
- while(($file = readdir($dir)) !== false)
- //echo $target_path2;
- {
- if(is_file($target_path2))
- {
- $filex = intval(substr($file, 0, strlen($file)-4));
- //echo $filex;
- if($filex >= $x)
- {
- $x = $filex + 1;
- //echo $x;
- }
- }
- }
- rename($target_path2, $target_path.$x.$extension);
- /* echo "The file ". basename($_FILES['uploadedfile']['name']).
- " has been uploaded"; */
- $fh = fopen($myFile, 'w');
- fwrite($fh, "The file ". basename($_FILES['uploadedfile']['name']).
- " has been uploaded to: ". $targetpath);
- fclose($fh);
- header("Location: /wherewillienduptoday/");
- } else{
- echo "There was an error uploading the file, please try again!";
- }
- ?>
Add Comment
Please, Sign In to add comment