像往常一样,这里是我学到很多东西的地方.我现在有了新的东西需要学习:
我有一个HTML格式:
<tr><td width="16%">File attachment</td><td width="2%">:</td><td><input type="file" name="fileatt" /></td></tr>
Run Code Online (Sandbox Code Playgroud)
和mail.php:
$attachfile=$_POST["fileatt"];
Run Code Online (Sandbox Code Playgroud)
和一个正确的swiftmailer代码发送电子邮件;
我已经google了,我发现了许多例子如何发送附件与存储在网站上的文件,但我想在飞行中这样做.因此,当您提交按钮时,它会将其发送给人们而不是上传文件.
// Create the Transport
$transport = Swift_SmtpTransport::newInstance('mail.server.co.uk', 25)
->setUsername('user')
->setPassword('pass')
;
// Create the Mailer using your created Transport
$mailer = Swift_Mailer::newInstance($transport);
// Create a message
$message = Swift_Message::newInstance($subject)
->setFrom(array('emai@emai.com' => 'name'))
->setBody($html, 'text/html')
;
// Add alternative parts with addPart()
$message->addPart(strip_tags($html), 'text/plain');
// Send the message
$result = $mailer->send($message);
Run Code Online (Sandbox Code Playgroud)
有人可以帮我如何进行即时文件上传吗?提前致谢!!!
我正在尝试在 php 中的 public_html 之外创建一个文件:
fopen("/home/sites/foo.org/backup-ticketing/asu.sql";w)
但是我收到此错误消息。我确信我应该能够以某种方式做到这一点,只是我无法弄清楚。该文件夹的权限是711.
[Wed Aug 01 14:33:54 2012] [错误] [客户端 84.3.2.16] PHP 警告:fopen(/home/sites/foo.org/backup-ticketing/asu.sql) [function.fopen]: 失败打开流:第 4 行 /home/sites/foo.org/public_html/back/asu.php 中不允许进行操作
您能告诉我正确的做法是什么吗?
谢谢你的很多建议,现在我有一个额外的信息:
php.ini 是 public_html 中的问题,但是我想保持原样,但 /back/ 文件夹应该能够这样做。
这是我的设置:
file_uploads = Off
upload_tmp_dir = /var/php_tmp
upload_max_filesize = 0M
allow_url_fopen = Off
allow_url_include = Off
safe_mode = Off
display_errors = off
magic_quotes_gpc = off
magic_quotes_runtime = off
max_file_uploads=0
disable_functions=passthru,exec,phpinfo
open_basedir = /home/sites/foo.org/public_html/
Run Code Online (Sandbox Code Playgroud) 很抱歉这个愚蠢的问题,但是我看不到/不够好解决:
我有一个MySQL数据库和一个php表格,一切正常,但我不能只记录一条-可能是语法错误:
$SQL = "SELECT * FROM massfelh WHERE user = $uname AND pass = md5($pword)"; - this is working
$result = mysql_query($SQL); - this is too
$catg = $result['categ']; - help
$num_rows = mysql_num_rows($result); - this is ok too
echo $catg; - for test and I can't print it on screen
Run Code Online (Sandbox Code Playgroud)
数据库结构:id,user,pass,categ
我只需要categ(1或0),但它不会在屏幕上显示。
任何帮助将不胜感激-请说我也是愚蠢的:)
更新:
谢谢大家!!!!!对我有很大帮助。我为我的代码找到了最好的解决方案,但是所有答复都是正确的。再次感谢您,这将帮助您像我一样初学者:)再次感谢您