Uploading Files
Posted: Mon May 26, 2003 12:30 pm
I'm making a game out of php online... I'm trying to get it so you can upload files onto the game, and the name of that file would be the $hid.
The $hid is already posted on the page, thats just that part of the code. That part of the code works fine. What I want it to do, though, is have the name be $hid. I am not farmiliar with the upload php script, so I don't know how to make it with the code I got from php.net.
mod_edit: enabled bbcode and changed
Code: Select all
<form enctype="multipart/form-data" action="upload.php" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="100000">
<input type="hidden" name="hid" value="$hid">
Send this file: <input name="$hid" type="file">
<input type="submit" value="Send File">
</form>Code: Select all
<?php
$hid = $_POST['hid'];
// In PHP earlier then 4.1.0, $HTTP_POST_FILES should be used instead of $_FILES.
// In PHP earlier then 4.0.3, use copy() and is_uploaded_file() instead of move_uploaded_file
$uploaddir = '/images/';
print "<pre>";
if (move_uploaded_file($_FILES['$hid']['tmp_name'], $uploaddir . $_FILES['$hid']['name'])) {
print "File is valid, and was successfully uploaded. Here's some more debugging info:\n";
print_r($_FILES);
} else {
print "Possible file upload attack! Here's some debugging info:\n";
print_r($_FILES);
}
?>Code: Select all
toCode: Select all
for the second block[/size]
What would I have to change in there for this to work? $uploaddir = '/images/'; and on that, can you make it go to another site. I own another site but it doesn't host php, and I dont want to use too much storage on this site... Would that be possible?
Thanks, Dani