Ask coding questions

← Back to all posts
Does Repl support the public file uploads for a repl?
desbest (0)

What if I have a PHP script and I want the general public to view my repl online to then upload a file using the repl, of which my code will do something with that upload.

Does Repl support the public file uploads for a repl?

Comments
hotnewtop
Coder100 (18917)
  1. no, because that's a security risk, a hacker could just spam uploading files.
    However, it's technically true, programmatic file creations will be saved if you go on the site every so often.
desbest (0)

@Coder100 What if the file is stored temporarily? What if the file is automatically deleted once the user leaves the web page?

Coder100 (18917)

@desbest read the second part
yes then it's technically possible, but by then you might as well use something like localStorage or cookies.

desbest (0)

@Coder100 What if the file I want the user to upload is 9MB? That exceeds the 8MB limit that web browsers allow websites to store in cookies, local storage, session storage and indexed db.

Coder100 (18917)

@desbest what?
upload a file?
if you don't make the file persist what's the point

desbest (0)

@Coder100 There's plenty of use cases for this, someone just needs to come up with a good idea, and they will.

In my instance uploading a HTML file that someone saved using their web browser, then using a scraping library to extract the relevant information from the file then output that part in a serialised format like xml, json, yaml or something esoteric. The user can then copy and paste this serialised output to either save it or use it somewhere else that requires it.

Coder100 (18917)

@desbest why do you need to use storage for that then? why not just store that in a variable?

Coder100 (18917)

or maybe even better yet, why not just submit it to a post request via a form? You would still have to do that for a file too @desbest

desbest (0)

@Coder100 Hello. For a post request being sent through a form using PHP, the content of the file is not stored in the post data. The post array will contain the following keys.

  • tmp_name
  • name
  • size
  • type
  • error

So unless Replit allows file uploads or even temporary file uploads where the file deletes itself once the user leaves the web page, I don't think extracting the contents of an uploaded file using post data will work.

Files uploaded with php are stored in the server's temporary directory until they are saved (or copied) into a folder or path of the programmer's choosing.

Coder100 (18917)

@desbest it's not?
i swear there was a multipart/form-data that allowed for that

desbest (0)

@Coder100 I've just tried it now and the contents of the file is not stored in the post date when using PHP. I've just tried it now. Look at this. So it looks like it's not possible.

https://replit.com/@desbest/PHP-File-Uploading-from-Tutorials-Point