-2

So I have a piece of html that uses a form tag to send a file to process.php, then I need to download that file to the server.

HTML:

<form action="process.php" method="post">
  File: <input type="file" name="file"><br><br>
  <input type="submit">
</form>

then in process.php I need something like this:

<?php download_file_to_server($_GET["file"]); ?>

I've looked all over the net but I couldn't find anything, please help.

Here is the full html:

<html>
  <head>
    <title>XSS Test</title>
  </head>
  <body>
    <h1>XSS TEST</h1>

    <form action="process.php" method="post">
      File: <input type="file" name="file"><input type="submit">
    </form>
  </body>
</html>
name
  • 63
  • 7
  • 2
    "download to server" is an oxymoron. – Garr Godfrey May 07 '22 at 00:19
  • You access the file using `$_FILES` variable. I'm not exactly sure what you mean by download. Did you want to create a download link so the client can download it after they've uploaded it? – Garr Godfrey May 07 '22 at 00:22
  • @GarrGodfrey lets say you have a website hosted on python, you download a file inputted from the user, the file goes to the directory the python file is in. – name May 07 '22 at 00:26
  • 3
    I don't think python works that way, either. Files get written to some temporary location on disk. PHP or python, you get a temporary file name. For php, it's `$_FILES["file"]["tmp_name"]` – Garr Godfrey May 07 '22 at 00:33
  • @GarrGodfrey is it possible to write a file using the `$_FILES` variable? – name May 07 '22 at 00:36
  • write it where? depends on the access rights the server process runs with, and if you can find a folder where it has write access. You can write files with PHP. $_FILES just gives info about the uploaded file (temp name, size, mime type, error info) – Garr Godfrey May 07 '22 at 00:50
  • @GarrGodfrey write it to the server directory – name May 07 '22 at 01:04
  • 1
    Maybe this help you? https://stackoverflow.com/a/3509388/8485567 – Bernard Wiesner May 07 '22 at 01:12
  • @name you mean web root folder? In general, probably not because your process should not have write access to the root web folder. You'll need to set up file permissions in a subfolder that is writable, and then you can copy the file to that web folder. – Garr Godfrey May 07 '22 at 02:21
  • @GarrGodfrey I guess I'd just put it in a directory – name May 07 '22 at 13:59

0 Answers0