问题描述
我正在开发一个文章发布实用程序,我正在使用包含在表单中的 Froala 的 WYSIWYG textarea 文本编辑器,在将文章的基本信息存储在数据库中后,我想将上传的图像存储在文本编辑器中在服务器上,问题是当我使用他们的 PHP SDK 存储文档中提到的图像时,出现此错误:Fieldname 不正确。它必须是:文件
这是表单的html:
<form method="post" class="mt-5" action="<?PHP echo htmlspecialchars($_SERVER['PHP_SELF']);?>">
<div class="form-group row justify-content-center">
<div class="col-sm-9">
<label for="uname" style="color:#B1DDF1;"><b>Your Article's title</b></label>
<input type="text" id="focusedInput" class="form-control" name="title" placeholder="Make it creative!...">
</div>
</div>
<div class="form-group mt-2">
<label for="comment" style="color:#B1DDF1;"><b>Content goes here...</b></label>
<div id="editor"><textarea class="form-control" cols="200" rows="200"id='edit' name="file" placeholder="Type some text"><h1>This is a heading</h1>
<p>start writing your article here!</p></textarea></div>
</div>
<div class=" row mt-2 justify-content-center">
<input type="submit" class=" col-xs-6" value="Publish me!">
</div>
</form>
$lastid=$conn->lastInsertId(); // get the new article's id for ressources management
$newarticfold="../LIGHT/articles_ressources/".$lastid;
try{
if(mkdir($newarticfold)){
require("wysiwygPHP/lib/FroalaEditor.PHP");
$path="/Freelancing/CarthageP/test/LIGHT/articles_ressources/".$lastid."/"; //specifying the path from $_SERVER["DOCUMENT_ROOT"]
$resp=FroalaEditor_Image::upload($path);
echo("<div class='alert alert-success'>yaaay images got uploaded yaaaaay</div>");
}
}
我尝试将 textarea 的名称更改为文件,多次阅读文档,并尝试在 google 上搜索错误消息,但没有找到任何相关信息,导致此类问题的可能原因是什么?是固定的吗?预先非常感谢您!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)