我正在尝试让这段代码再次运行.即使我正在尝试访问的文件名,我做了一些不回显的内容.请帮忙,我已经看了一个多小时已经没有用了:(注意:我甚至不能在这里回应$ name
<?php
error_reporting(0);
if($_POST['submit']){
//file uploading
$name = basename($_FILES['upload']['name']); //name plus extention
print_r($_FILES['upload']);
$t_name = $_FILES['upload']['tmp_name'];
$dir = 'gallery_i';
$thumbs = 'gallery_t';
if(move_uploaded_file($t_name,$dir.'/'.$name)){
$resizeObj = new resize($dir.'/'.$name);//Resize image (options: exact, portrait, landscape, auto, crop)
$resizeObj -> resizeImage(200, 200, 'auto'); //Save image
$resizeObj -> saveImage($thumbs.'/'.$name, 100);
echo 'file upload nicely';
//file upload successfull
}
}
?>
<div class='home'>
<form method='post' action='other.php'>
Name: <input class='reg' type='text' name='prodname'/><br/><br/>
Description:<br/> <textarea class='reg' name='description' rows="4" cols="40"> </textarea> <br/><br/>
<input type='file' name='upload' />
<input type='submit' value='submit' name='submit'/>
</form>
</div>
Run Code Online (Sandbox Code Playgroud)
您需要使用mutlipart表单数据来上传文件:
设置表单属性: enctype="multipart/form-data"
http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.2
这里简单的教程:http://www.w3schools.com/php/php_file_upload.asp