日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

php向指定文件发送消息,PHP-将文件发送给用户

發布時間:2025/5/22 php 22 豆豆
生活随笔 收集整理的這篇文章主要介紹了 php向指定文件发送消息,PHP-将文件发送给用户 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

白衣非少年

好的,所以我不是PHP的專家,我只能歸功于將其他幾段PHP放在一起以實現我需要的功能,我認為最好將這個解決方案發布在一些要求同樣的問題,但我自己無法工作。似乎在任何地方都沒有解決方案,所以在這里。它對我有用...好吧,首先我創建了PDF表單,并添加了一個按鈕,然后提交表單。在此提交表單的操作中,我告訴它以PDF格式發送完整的文檔。然后,我給它提供了指向php頁面的URL鏈接,例如mail_my_form.php。然后,我創建了一個php表單,并將其命名為與上面相同。mail_my_form.php的最后一件事是在根目錄中創建一個名為pdfs的文件夾。此php代碼的位置。(因此,如果將php放在名為email的文件夾中,然后在email文件夾中,您需要另一個名為pdfs的文件夾)現在,此腳本的作用是:將PDF保存為文件名pdfs。然后,它將文件附加到電子郵件并發送。然后從文件夾pdfs中刪除該文件以節省空間。(如果需要,您也可以刪除功能以將表單保存在FTP上。這里是。<?php ?

$fileatt?=?date("d-m-Y-His")?.?".pdf";??//?Creates?unique?PDF?name?from?the?date?copy('php://input',"pdfs/".$fileatt);?//?Copies?the?pdf?form?data?to?a?folder?named?pdfs?$fileatt?=?"pdfs/".$fileatt;?//?Path?to?the?file?gives?the?pdfs?folder?plus?the?unique?file?name?we?just?assigned$fileatt_type?=?"application/pdf";?//?File?Type?$fileatt_name?=?"Application?Form_".$fileatt.".pdf";?//?Filename?that?will?be?used?for?the?file?as?the?attachment?when?it?is?sent$email_from?=?"mywebsite";?//?Who?the?email?is?from?$email_subject?=?"Completed?online?Applications";?//?The?Subject?of?the?email?$email_message?=?"Please?find?a?recent?online?application?attached.

";

?$email_message?.=?"Any?problems?please?email?me...

";?//?Message?that?the?email?has?in?it?$email_to?=?"youremail@yourserver.com";?//?Who?the?email?is?to?$headers?=?"From:?".$email_from;//no?need?to?change?anything?else?under?this?point$file?=?fopen($fileatt,'rb');?$data?=?fread($file,filesize($fileatt));?fclose($file);?$semi_rand?=?md5(time());?$mime_boundary?=?"==Multipart_Boundary_x{$semi_rand}x";?$headers?.=?"\nMIME-Version:?1.0\n"?.?"Content-Type:?multipart/mixed;\n"?.?"?boundary=\"{$mime_boundary}\"";?$email_message?.=?"This?is?a?multi-part?message?in?MIME?format.\n\n"?.?"--{$mime_boundary}\n"?.?"Content-Type:text/html;?charset=\"iso-8859-1\"\n"?.?"Content-Transfer-Encoding:?7bit\n\n"?.?$email_message?.=?"\n\n";?$data?=?chunk_split(base64_encode($data));?$email_message?.=?"--{$mime_boundary}\n"?.?"Content-Type:?{$fileatt_type};\n"?.?"?name=\"{$fileatt_name}\"\n"?.?//"Content-Disposition:?attachment;\n"?.?//"?filename=\"{$fileatt_name}\"\n"?.?"Content-Transfer-Encoding:?base64\n\n"?.?$data?.=?"\n\n"?.?"--{$mime_boundary}--\n";?$ok?=?@mail($email_to,?$email_subject,?$email_message,?$headers);?if($ok)?{?unlink($fileatt);?//NOW?WE?DELETE?THE?FILE?FROM?THE?FOLDER?pdfs?Header("Location:?nextpage.php");?//where?do?we?go?once?the?form?has?been?submitted.}?else?{?die("Sorry?but?the?email?could?not?be?sent.?Please?go?back?and?try?again!");?}??>希望對您有所幫助。理查德·威廉姆斯

總結

以上是生活随笔為你收集整理的php向指定文件发送消息,PHP-将文件发送给用户的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。