我尝试将文件路径放入邮件中以便在没有 ftp 的情况下下载
$nomecognome = $_POST['cname'];
$email = $_POST['cemail'];
$biography = $_POST['ctext'];
$datanascita = $_POST['cdata'];
$controllo = $_POST['ccontrol'];
$files = $_FILES['uploader'];
if(empty($controllo)){
我清除名称
$accenti = array( 'à' , 'è' , 'é' , 'ì' , 'ò' , 'ù' , '\'' , ' ' );
$noaccenti = array( 'a' , 'e' , 'e' , 'i' , 'o' , 'u' , '_' , '_' );
$author = strtolower( str_replace( $accenti , $noaccenti , $nomecognome ) );
为将来的比较文件 ext 创建一个数组
$allowedExtensions = array('jpg', 'jpeg', 'png', 'bmp', 'tiff', 'gif', 'pdf');
控制表单是否为空
if ( !empty ( $files ) ){
开始上传图片
foreach ($files['name'] as $key => $value) {
if(is_uploaded_file($files['tmp_name'][$key]) && $files['error'][$key] == 0) {
使用用户名和随机数加上文件名为文件创建一个唯一名称
$filename = $files['name'][$key];
$filename = $author.rand(0,99).$filename;
//array_push($path, 'http://www.magic-promo.it/uploads/'.$author.$value);
检查文件是否被移动
if( move_uploaded_file( $files['tmp_name'][$key], 'uploads/'. $filename) ) {
在这里,我想创建每个图像路径的数组以发送邮件
foreach ($filename as $filenames) {
$pathfile[] = array($filename);
}
$body = implode(',', $pathfile);
echo $body; //to view the list of path
}
else{
echo move_uploaded_file($files['tmp_name'][$key], 'uploads/'. $filename);
echo 'file non uploadato';
}
}
else {
echo 'The file was not uploaded.';
}
}
我感谢您的帮助!