2012-05-02 5 views
0

확장자없이 저장하는 웹 서버에 파일을 업로드하는 페이지가 있습니다.PHP는 이메일을 보내지 않고 파일을 보냅니다.

example.doc은 현재 시간 (1234567890)으로 저장되지만 확장자는 없습니다.

이 작동합니다.이 문제는 없습니다.

내가 문제가되는 것은 나중에 이메일 주소로 이메일로 문서를 보내는 것입니다. 나는 파일의 확장자를 포함한 원래의 이름을 할당하고 싶다.

모든 데이터는 내 데이터베이스에 저장됩니다. 의 이름과 확장.

예를 들어이 파일 "1234567890"을 example.doc로 이메일 주소로 보내고 싶습니다.

+0

코드/시도한 것을 포함해야합니다. –

+0

괜찮습니다. 넌 뭘해야 할 지 알 잖아. 작동하지 않는 것은 무엇입니까? –

+0

그게 그거야. 이 일을 어떻게 할 수있는 일은 할 수 없습니다. – Lalajee

답변

0

CODE IT는 이미 파일을 추가 한 경우 브라우저가 확인합니다

작동 원리

<html> 
    <head> 
    <title>My First File Sender</title> 
    <meta charset="utf8 "> 
    </head> 
    <body> 

    <?php 
     if (!isset($_POST["file"])) 
     { 
     echo '<form method="POST" action="upload.php" enctype="multipart/form-data"><input type="file" name="fileToUpload" id="fileToUpload"><br><input type="submit" value="Send File"></form>'; 
     }else { 
     /* 
     Settings start here 
     */ 
     $target_dir = "files/"; 
     $name = "John Doe"; 
     $email = "[email protected]"; 
     $subject = "New File"; 
     /* 
     Settings end here 
     */ 
     $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]); 
     $uploadOk = 1; 
     $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION); 
     $msg = ' 
     Dear ' . $name . ',<br> 
     A new file has been sent, it will be saved in the uploads file.<br><br> 

    Thank you,<br> 
    Automated System 
    '; 
     mail($email,$subject,$msg); 
     echo "Thank You."; 
     } 

    ?> 




    </body> 
    </html> 

. 그것은 파일을 선택하라는 메시지를 표시합니다

: NOT 경우

.

TRUE 경우 :

$target_dir이 동일 무엇에 파일을 업로드합니다.

그런 다음 $email과 같은 이메일을 보내주십시오.

메시지는 다음과 같이 보일 것입니다.

 
Dear John Doe, 
A new file has been sent, it will be saved in the uploads file. 


Thank you, 
Automated System 
관련 문제