PHP: <?php // Edit upload location here $destination_path = getcwd().DIRECTORY_SEPARATOR; $result = 0; $target_path = $destination_path . basename( $_FILES['myfile']['name']); if(@move_uploaded_file($_FILES['myfile']['tmp_name'], $target_path)) { $result = 1; } sleep(1); ?> <script language="javascript" type="text/javascript">window.top.window.stopUpload(<?php echo $result; ?>);</script> как переименовать файл если с таким именем уже существует? или сразу имя файла на случайный
PHP: <?php // Edit upload location here $destination_path = getcwd().DIRECTORY_SEPARATOR; $result = 0; $target_path = $destination_path . basename( $_FILES['myfile']['name']); $randval = time(); $newname = $randval . $_FILES["userfile" . $filecounter]['name']; if(@move_uploaded_file($_FILES['myfile']['tmp_name'], $newname)) { $result = 1; } sleep(1); ?> <script language="javascript" type="text/javascript">window.top.window.stopUpload(<?php echo $result; ?>);</script> но он не сохраняет расширение файла .jpg .gif .png ...
PHP: <?php // Edit upload location here $destination_path = getcwd().DIRECTORY_SEPARATOR; $result = 0; $target_path = $destination_path . basename( $_FILES['myfile']['name']); $imagetypes = array( 'image/png' => '.png', 'image/gif' => '.gif', 'image/jpeg' => '.jpg', 'image/bmp' => '.bmp'); $ext = $imagetypes[$_FILES['myfile']['type']]; $randval = time(); $newname = $randval . $ext; if(@move_uploaded_file($_FILES['myfile']['tmp_name'], $newname)) { $result = 1; } sleep(1); ?> <script language="javascript" type="text/javascript">window.top.window.stopUpload(<?php echo $result; ?>);</script> получилось