I have two servers, one with my site, the other for storage. I'm trying to have a page where someone can upload a file to a storage server, I hope to use a form message to get it there. I wrote very simple code to fix this problem, and I have problems. It works fine if I change the action to .php, which saves it on the same server, but when I change it to my storage server, it cannot load and will show me an โelseโ echo that failed to load. / p>
HTML on my web server:
<form action="http://storageServer/upload_file.php" method="post" enctype="multipart/form-data"> <label for="file">Filename:</label> <input type="file" name="file" id="file" /> <br /> <input type="submit" name="submit" value="Submit" /> </form>
PHP on my storage server:
<?php $folder = "files/"; $path = $folder . basename( $_FILES['file']['name']); if(move_uploaded_file($_FILES['file']['tmp_name'], $path)) { echo "The file ". basename( $_FILES['file']['name']). " has been uploaded"; } else{ echo "There was an error uploading the file, please try again!"; } ?>
.php is located in the html folder with the files folder.
Any reason the file doesn't get to the server you see?
Milksnake12
source share