gpt4 book ai didi

php上传文件功能

转载 作者:可可西里 更新时间:2023-11-01 00:11:43 25 4
gpt4 key购买 nike

我正在尝试编写一个通过 html 表单上传文件的脚本。当我点击提交时没有任何反应。

文件:upload_form.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>

<form action="do_upload.php" method="post" enctype="multipart/form-data"></form>
<p><strong>File to upload</strong></p>
<p><input name="img1" type="file" size="30" /></p>
<p><input name="submit" type="submit" value="Upolad File" /></p>

</body>
</html>

文件:do_upload.php

<?php
if ($_FILES[img1] != "" {
@copy($_FILES[img1] [tm_name], "/tmp" .$_FILES[img1][name])
or die("couldnt copy the file");
} else {
die("no file specified");
}
?>

<HTML>
<head>
<title>Successfull File Upload</title>
</head>
<body>

<h1>Success</h1>
<p>You sent: <? echo $_FILES[img1][name]; ?>, a <? echo $_FILES[img1][size]; ?>byte filw with a mime type of <? echo $_FILES[img1][type]; ?></p>

</body>
</HTML>

最佳答案

<form action="do_upload.php" method="post" enctype="multipart/form-data"></form>
<p><strong>File to upload</strong></p>
<p><input name="img1" type="file" size="30" /></p>
<p><input name="submit" type="submit" value="Upolad File" /></p>

<form action="do_upload.php" method="post" enctype="multipart/form-data">
<p><strong>File to upload</strong></p>
<p><input name="img1" type="file" size="30" /></p>
<p><input name="submit" type="submit" value="Upolad File" /></p>
</form>

if ($_FILES[img1] != "" {

if (isset($_FILES['img1'])) {

关于php上传文件功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2650262/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com