作者:心上锁退 | 来源:互联网 | 2017-05-13 02:18
<html><head><metacharset="utf8"><title>uploadtitle>head><body><formaction="upload_file.php"method="post"enctype="multipart/form-data"><labelfor="file">Filename:label><inputtype="file"name="file"id="file" /><br /><inputtype="submit"name="submit"value="submit" /><br />form>body>html>
if(($_FILES['file']['type'] == "image/gif")||
($_FILES['file']['type'] == "image/jpeg")||
($_FILES['file']['type'] == "image/pjpeg")&&
($_FILES['file']['size'] <20000))
{
if ($_FILES["file"]["error"] > 0)
{
echo"Error: " . $_FILES["file"]["error"] . "
";
}
else
{
echo"";
echo"";
echo"";
echo"Upload: " . $_FILES["file"]["name"] . "
";
echo"Type: " . $_FILES["file"]["type"] . "
";
echo"Size: " . ($_FILES["file"]["size"] / 1024) . " Kb
";
echo"Stored in: " . $_FILES["file"]["tmp_name"];
echo"";
echo"";
if(file_exists("upload/" . $_FILES['file']['name']))
{
echo$_FILES['file']['name']."already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"/usr/local/nginx/html/upload/" . $_FILES["file"]["name"]);
echo"Stored in: " . "/usr/local/nginx/html/upload/" . $_FILES["file"]["name"];
}
}
}
else
{
echo"Invaild file";
}
?>
').addClass('pre-numbering').hide();
$(this).addClass('has-numbering').parent().append($numbering);
for (i = 1; i <= lines; i++) {
$numbering.append($('
').text(i));
};
$numbering.fadeIn(1700);
});
});
以上就介绍了php上传文件代码,包括了上传文件,php方面的内容,希望对PHP教程有兴趣的朋友有所帮助。