Results 1 to 7 of 7
Thread: PHP -
Hybrid View
-
6th September 2016 21:32 #1Registered User
Join Date: Sep:2016
Location:
Posts: 18
PHP -
! PHP, . , Word 2003, 2010 Notepad. , , , , , . - . ! PHP . :
:Code:<?php if ($_FILES['file']['name'] !=""){ if ($_FILES['file']['name'] != ""){ if ($_FILES['file']['type'] == "image/jpeg"){ copy($_FILES['file']['tmp_name'], $_POST['name']) or die (" !"); }else{ die(" !"); } }else{ die(" !"); } } # . # copy() : copy(""," ") # ?> <html> <head> <title> </title> <meta http-equiv="Content-Type" content="text/html; charset=windows-1251"> </head> <body> <?php $name = $_FILES['file']['name']; // $size = $_FILES['file']['size']; // ( ) $type = $_FILES['file']['type']; // ?> <a href="<?php echo ("$name"); ?>"></a> <b><?php echo ("$size"); ?></b> <b><?php echo ("$type"); ?></b> ! </body> </html>
Code:<html> <head> <title> </title> <meta http-equiv="Content-Type" content="text/html; charset=windows-1251"> </head> <body> <form action="upload.php" method="post" enctype="multipart/form-data"> :<input type="file" name="file" size="40"><br> :<input type="text" name="name" size="50"> <input type="submit" value=""> </form></body></html>
-
7th September 2016 10:14 #2
, MIME :
if ($_FILES['file']['type'] == "image/jpeg"){
, PHP. .
-
7th September 2016 11:35 #3
- . 100 ( )
. PHP .
is_uploaded_file($file['tmp_name']).
,
if (move_uploaded_file($file['tmp_name'], $new_filename)) {... success ....} else { failure...... }.
. . , , . , (). , .
, MIME- . MIME-.
( ).
Code:<?php $message = array( 'type' => 'warning', 'text' => ' !' ); if (isset($_FILES['file']) && is_uploaded_file($_FILES['file']['tmp_name'])) { $file = $_FILES['file']; $exts = 'doc,docx,txt,jpg,jpeg,gif,png'; $origext = ''; $validext = false; $lastdot = strtolower(strrpos($file['name'], '.')); // check extension if ($lastdot) { $origext = substr($file['name'], $lastdot + 1); if ($origext !== '' && strpos($origext, ',') === false) { $validext = strpos($exts, $origext) !== false; } } if ($validext) { // determine destination path $fpath = date("Y-m-d--H-i-s").DIRECTORY_SEPARATOR.$file['name']; if (move_uploaded_file($file['tmp_name'], $fpath)) { $message['type'] = 'success'; $message['text'] = " <a href=\"$fpath\">{$file['name']}</a> {$file['size']} \"$origext\" ."; } else { $message['type'] = 'error'; $message['text'] = ' !'; } } else { $message['type'] = 'error'; $message['text'] = ' !'; } } ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1251"> <title> </title> <style> .warning { color: brown; } .error { color: red; } .success { color: darkgreen; } </style> </head> <body> <div class="<?=$message['type']?>"> <?=$message['text']?> </div> </body> </html>
-
7th September 2016 18:34 #4Registered User
Join Date: Sep:2016
Location:
Posts: 18
Tedych, .
- - - - - -
, , , :
Warning: move_uploaded_file(2016-09-07--18-29-52\Pano_1.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in C:\xampp\htdocs\uploaddocs\upload.php on line 24
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\xampp\tmp\php4281.tmp' to '2016-09-07--18-29-52\Pano_1.jpg' in C:\xampp\htdocs\uploaddocs\upload.php on line 24
?
-
7th September 2016 21:01 #5
, ,
.
$fpath = date("Y-m-d--H-i-s").DIRECTORY_SEPARATOR.$file['name'];
$subdir = date("Y-m-d--H-i-s");
if (!is_dir($subdir)) mkdir('./'.$subdir, 0777, true);
$fpath = $subdir.DIRECTORY_SEPARATOR.$file['name'];
-
7th September 2016 22:17 #6Registered User
Join Date: Sep:2016
Location:
Posts: 18
! ! . .




Reply With Quote
Lenovo ThinkPad 15 IdeaPad 15
5th May 2023, 22:16 in