这是我在main
中使用的代码 <html>
<body>
<form action="welcome.php" method="post" enctype="multipart/form-data">
<input id="foto1slct" name="foto1" size="45" type="file" value="Upload" accept="image/*">
<input id="invia" type="submit" value="Invia">
</input>
</form>
</body>
</html>
我在welcome.php中使用这段代码将上传的文件附加到html
中 <html>
<body>
<?php $file = 'Italia/categoria.html'; ?>
<?php $current = file_get_contents($file); ?>
<?php $current .= $_POST["foto1"]; ?>
<?php file_put_contents($file, $current); ?>
</body>
</html>
答案 0 :(得分:-1)
您的代码中有两个错误,我修复了
<html>
<body>
<?php
$file = 'categoria.html';
$fileName = $_FILES["file1"]["name"];
$fileTmpLoc = $_FILES["file1"]["tmp_name"];
$newfile="tempareryloc/$fileName";
move_uploaded_file($fileTmpLoc,$file);
$current = file_get_contents($file);
$current .= file_get_contents($newfile);
unlink($newfile);
?>
</body>
</html>
现在它似乎工作但是,它将文本中的图像保存到创建的html中。 我们能找到解决方案吗?