我一直在尝试在PHP中使用move_uploaded_file函数但是,没有任何工作,我希望用户能够上传文件,然后将文件保存到我的文件夹(p),下面是我的代码,任何帮助会很棒。
的index.php:
<html>
<head>
<title>test</title>
</head>
<body bgcolor="black">
<font color="white">
<form action="upload.php" method="post">
<input type="file" name="file" id="file">
<input type="submit" value="Submit">
</form>
upload.php的:
<html>
<head>
<title>Helo World</title>
</head>
<body bgcolor="black">
<font color="white">
<?php
move_uploaded_file($_FILES["file"]["tmp_name"], 'p/file.jpg');
?>
答案 0 :(得分:1)
你没有放置属性
<form action="upload.php" method="post" enctype="multipart/form-data">
答案 1 :(得分:1)
首先,您需要将表单设置为接受上传的文件。所以表单需要有enctype =&#34; multipart / form-data&#34;比如下面的代码:
import numpy as np
import pandas as pd
from scipy.stats import fisher_exact
most_indicative_medication = {}
rx_list = list(meps_meds.rxName.unique())
disease_list = list(meps_base_data.columns.values)[8:]
for i in disease_list:
print i
rx_dict = {}
for j in rx_list:
subset = base[['id', i, 'rxName']].drop_duplicates()
subset[j] = subset['rxName'] == j
subset = subset.loc[subset[i].isin(['Yes', 'No'])]
subset = subset[[i, j]]
tab = pd.crosstab(subset[i], subset[j])
if len(tab.columns) == 2:
rx_dict[j] = fisher_exact(tab)[1]
else:
rx_dict[j] = np.nan
most_indicative_medication[i] = min(rx_dict, key=rx_dict.get)
php会是这样的:
<html>
<head>
<title>test</title>
</head>
<body bgcolor="black">
<font color="white">
<form action="upload.php" method="post" enctype="multipart/form-data">
<input type="file" name="file" id="file">
<input type="submit" value="Submit" name="submit">
</form>