|
Upload Image + rename
|
|||
---|---|---|---|
#18+
Подскажите как написать, или где взять скрипт который мог бы проверить формат файла, размер, и главное чтобы была возможность дать новое имя файлу. ... |
|||
:
Нравится:
Не нравится:
|
|||
15.08.2003, 15:01 |
|
Upload Image + rename
|
|||
---|---|---|---|
#18+
Perl или PHP ? Если PHP: Если ты Upload'ишь файл, то его имя на сервере хранится в переменной с названием из формы, типа если в форме ты пишешь: <input type='file' name='picture'> то он загрузит его на сервер и имя файла на сервере будет в переменной $picture (кстати, это временный файл, он потом сам удалится) Если ты хочешь положить его куда-нибудь к себе в каталог ты просто используешь copy ($picture, "новое имя файла"). Размер определяется какой-то из функций php для файлов (не помню точно какой) Что значит проверить формат ? ... |
|||
:
Нравится:
Не нравится:
|
|||
17.08.2003, 21:13 |
|
Upload Image + rename
|
|||
---|---|---|---|
#18+
Нашел скрипт который проверяет размер, расширение, наличие этого файла на сервере , только одно но не получается дать новое имя: uploadxit.php ////////////////////////////////////////////////////////////////////////////////////// <? if(!isset($upload)) { $upload = ""; } switch($upload) { default: include "configupxit.php"; echo " <center> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse: collapse\" bordercolor=\"#111111\" width=\"400\" id=\"AutoNumber1\"> <tr> <td bgcolor=\"#5E6A7B\" height=\"25\"> <p align=\"center\"><font size=\"2\"><b>Upload file</b></font></td> </tr> <tr> <td bgcolor=\"#818EA0\"><font size=\"2\">Options:</font><ul type=\"square\"> <li><font size=\"2\">file must to be $file_name - $file <b>"; if (($extensions == "") or ($extensions == " ") or ($ext_count == "0") or ($ext_count == "") or ($limit_ext != "yes") or ($limit_ext == "")) { echo "type files"; } else { $ext_count2 = $ext_count+1; for($counter=0; $counter<$ext_count; $counter++) { echo " $extensions[$counter]"; } } if (($limit_size == "") or ($size_limit != "yes")) { $limit_size = "any size"; } else { $limit_size .= " bytes"; } echo"</b></font></li> </ul> $file <form method=\"post\" action=\"uploadxit.php?upload=doupload\" enctype=\"multipart/form-data\"> <p align=\"center\"> <input type=file name='picture' size=30 style=\"font-family: v; font-size: 10pt; color: #5E6A7B; border: 1px solid #5E6A7B; padding-left: 4; padding-right: 4; padding-top: 1; padding-bottom: 1\"><br> <br> <button name=\"submit\" type=\"submit\" style=\"font-family: v; font-size: 10pt; color: #5E6A7B; border: 1px solid #5E6A7B; padding-left: 4; padding-right: 4; padding-top: 1; padding-bottom: 1\">Upload</button> </p> </form> <p> </td> </tr> <tr> <td bgcolor=\"#5E6A7B\" height=\"25\"> </td> </tr> </table> </center> "; break; case "doupload": include "configupxit.php"; $endresult = "<font size=\"2\">File successfully upload</font>"; if ($file_name == "") { $endresult = "<font size=\"2\">file not selected</font>"; }else{ if(file_exists("$absolute_path/$file_name")) { $endresult = "<font size=\"2\">Server already have file with this name </font>"; } else { if (($size_limit == "yes") && ($limit_size < $file_size)) { $endresult = "<font size=\"2\">too big file</font>"; } else { $ext = strrchr($file_name,'.'); if (($limit_ext == "yes") && (!in_array($ext,$extensions))) { $endresult = "<font size=\"2\">type not correct</font>"; }else{ @copy($file, "$absolute_path/$file_name") or $endresult = "<font size=\"2\">Error</font>"; } } } } echo " <center> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse: collapse\" bordercolor=\"#111111\" width=\"400\" id=\"AutoNumber1\"> <tr> <td bgcolor=\"#5E6A7B\" height=\"25\"> <p align=\"center\"><font size=\"2\"><b>Çàãðóçêà ôàéëà</b></font></td> </tr> <tr> <td bgcolor=\"#818EA0\"> <center> $endresult </center> </td> </tr> <tr> <td bgcolor=\"#5E6A7B\" height=\"25\"> </td> </tr> </table> </center> "; break; } ?> ////////////////////////////////////////////////////////////////////////////////////// configupxit.php <? $absolute_path = "/pub/home/prodaza8/htdocs/"; //Absolute path to where files are uploaded $size_limit = "yes"; //do you want a size limit yes or no. $limit_size = "90000"; //How big do you want size limit to be in bytes $limit_ext = "no"; //do you want to limit the extensions of files uploaded $ext_count = "2"; //total number of extensions in array below $extensions = array(".jpg", ".jpeg"); //List extensions you want files uploaded to be ?> ... |
|||
:
Нравится:
Не нравится:
|
|||
18.08.2003, 11:46 |
|
Upload Image + rename
|
|||
---|---|---|---|
#18+
В скрипте не разбирался, он слишком длинный и слишком много лишней информации. Чтобы переименовать файл, тебе нужно просто копировать его не также как и скрипт, а с другим именем. Т.е. строчка Код: plaintext 1.
дожна быть Код: plaintext 1.
... |
|||
:
Нравится:
Не нравится:
|
|||
18.08.2003, 18:54 |
|
|
start [/forum/topic.php?fid=23&msg=32237715&tid=1480465]: |
0ms |
get settings: |
10ms |
get forum list: |
13ms |
check forum access: |
4ms |
check topic access: |
4ms |
track hit: |
146ms |
get topic data: |
13ms |
get forum data: |
3ms |
get page messages: |
44ms |
get tp. blocked users: |
2ms |
others: | 14ms |
total: | 253ms |
0 / 0 |