php 图片上传
如何制作一个基本的PHP上传器?我希望我的图像保存在我的 htdocs/myfolder/
这是我的代码:
<form enctype="multipart/form-data" method="post" action="img_uploader.php"> <input type="file" name="fileToUpload" /><br /> <input type="submit" value="Upload File" /> </form>
How to make a basic PHP uploader? I want my images to save in my htdocs/myfolder/
Here is my code:
<form enctype="multipart/form-data" method="post" action="img_uploader.php"> <input type="file" name="fileToUpload" /><br /> <input type="submit" value="Upload File" /> </form>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
下面的代码是一个简单的示例,涉及图像或文件上传的所有方面,看一下并理解它
the code below is a simple example touching all the aspects of image or file upload take a look at it and understand it
这是我找到的用于文件上传的快速教程:
http://www.tizag.com /phpT/fileupload.php
我很快就读完了它,但它为您提供了一些安全内容的基本概念
Here is a quick tutorial I found for doing a file upload:
http://www.tizag.com/phpT/fileupload.php
I read through it pretty quick, but it gives you the basic idea with some safety stuff to boot
在这里指定您的目录路径,
用 uploadedfile 替换文件输入的名称,其余代码将正常工作
`
specify your directory path here
replace the name of file input with uploadedfile and rest code will work fine
`
正如下面的代码是工作示例:
中创建一个名为“myfolder”的文件夹
首先在 htdocs 文件夹[img_uploader.php]
As Your Code below is working example:
first create a folder with name "myfolder" in your htdocs folder
[img_uploader.php]
在工作目录中上传是可以的,但是,同时在数据库中上传是注意工作的,有人可以解决这个问题吗?亲切地。
函数 doInsert(){
if(isset($_POST['保存'])){
if ( $_POST['BRANCHNAME'] == "" || $_POST['BRANCHLOCATION'] == "" || $_POST['BRANCHCONTACTNO'] == "" ) {
$messageStats = false;
message("所有字段均为必填!","错误");
重定向('index.php?view=add');
}其他{
$branch = 新分支();
$branch->BRANCHNAME = $_POST['BRANCHNAME'];
$branch->BRANCHLOCATION = $_POST['BRANCHLOCATION'];
$branch->BRANCHCONTACTNO = $_POST['BRANCHCONTACTNO'];
$branch->BRANCHLEVEL = $_POST['BRANCHLEVEL'];
$branch->BRANCHSTATUS = $_POST['BRANCHSTATUS'];
$branch->BRANCHMANAGER = $_POST['BRANCHMANAGER'];
$branch->BRANCHDESCRIPTION = $_POST['BRANCHDESCRIPTION'];
//$branch->PICLOCATION = $_POST['PICLOCATION'];
}
}
In the working directory is fine work upload but, uploading in the database at the same time is note working any one solve this problem? kindly.
function doInsert(){
if(isset($_POST['save'])){
if ( $_POST['BRANCHNAME'] == "" || $_POST['BRANCHLOCATION'] == "" || $_POST['BRANCHCONTACTNO'] == "" ) {
$messageStats = false;
message("All field is required!","error");
redirect('index.php?view=add');
}else{
$branch = New Branch();
$branch->BRANCHNAME = $_POST['BRANCHNAME'];
$branch->BRANCHLOCATION = $_POST['BRANCHLOCATION'];
$branch->BRANCHCONTACTNO = $_POST['BRANCHCONTACTNO'];
$branch->BRANCHLEVEL = $_POST['BRANCHLEVEL'];
$branch->BRANCHSTATUS = $_POST['BRANCHSTATUS'];
$branch->BRANCHMANAGER = $_POST['BRANCHMANAGER'];
$branch->BRANCHDESCRIPTION = $_POST['BRANCHDESCRIPTION'];
//$branch->PICLOCATION = $_POST['PICLOCATION'];
}
}