本文介绍了在远程服务器上通过html& JavaScript的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图通过基于unix的服务器上的html页面来上传文件,但是我不知道如何将文件放在远程服务器上。保存文件。
I am trying to upload files through html page in our unix based server but I don't know how to take the files on remote server & save files there.
我写下面的代码请帮我连接一下。
I write the following code please help me to connect it.
<html>
<head>
<script type="text/javascript">
function Upload()
{
var filename = document.getElementById("filename").value;
var storepath = "HOSTURL/Foldername";
}
</script>
</head>
<body>
<form action="" method="post" enctype="multipart/form-data" >
<input type="file" name="filename" />
<input type="submit" value="Upload" onclick="Upload" />
</form
</body>
</html>
推荐答案
PHP会是更好的选择。 ($ set)($ _POST [Upload]))
{
$ b
PHP would be a better choice for this.
<?php
if( isset( $_POST["Upload"] ) )
{
$target_path = "uploads/";
$target_path = $target_path . basename( $_FILES['filename']['name']);
if(move_uploaded_file($_FILES['filename']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['filename']['name']). " has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
}
?>
<form method="post" enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" >
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
<input type="file" name="filename" />
<input type="submit" value="Upload" name="Upload" />
</form>
这篇关于在远程服务器上通过html& JavaScript的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!