I'm trying to add to Kusaba X, the imageboard script, a way to upload files from remote locations.
The class does a lot of checks on $_FILES['imagefile']['name']
and $_FILES['imagefile']['size']
, want to reuse them for a file upload from remote URI. In upload.class.php
I have a variable containing the URI of the pic I want to upload. I don't want to rewrite it all of make a long bunch of if/elses or practically copy that code, was thinking if there was a way to use them as they are?
Tried to ($imgURI is the http:// location of the file):
$_FILES['imagefile']['name'] = $imgURI;
and
$imagefile_name = fopen($imgURI,"rb");
$_FILES['imagefile']['name'] = $imagefile_name;
but no luck.
I could make a master variable on which all checks are run and make a big find and replace, but what should it contain?
Hope the question is clear enough, it's been a while since I did any PHP so I might be missing something obvious. Thank you for any ideas/thoughts on this
$_FILES['imagefile']['name']
contains the name of the file on the client PC, which is usually just used as a hint when naming the permanent file on the local system. The element of $_FILES
that contains the name of a file that can be read is $_FILES['imagefile']['tmp_name']
.
However, this is generally expected to be a local filename. It's usually used in code like move_uploaded_file($_FILES['imagefile']['tmp_name'], $permanent_file)
. This is basically just renaming the temporary file, and won't work with a URL.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With