File Upload

4 posts Page 1 of 1
Contributors
Lewis
Coding God
Coding God
Posts: 1564
Joined: Sun Dec 20, 2009 2:12 pm

File Upload
Lewis
Index.php:
Code: Select all
<form enctype="multipart/form-data" action="process.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>
Process.php
Code: Select all
<?php
$target_path = "uploads/";

$target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
    echo "The file ".  basename( $_FILES['uploadedfile']['name']). 
    " has been uploaded";
} else{
    echo "There was an error uploading the file, please try again!";
}
?>
Make shure uploads is CHMOD'd to 0777 or 777
Image
User avatar
Esky
VIP - Donator
VIP - Donator
Posts: 86
Joined: Tue Dec 22, 2009 11:36 am

Re: File Upload
Esky
Sick! is there anyway you can password is to only allow myself to upload files?
Current Project: Server Browser - Beta & Text based MMORPG
Image
Lewis
Coding God
Coding God
Posts: 1564
Joined: Sun Dec 20, 2009 2:12 pm

Re: File Upload
Lewis
Ohh yeah recomended to not use that :D But you could put it in your cpanel?
well if you make a custom one or something xD
Image
User avatar
Scottie1972
Codenstuff Elite
Codenstuff Elite
Posts: 953
Joined: Thu Jan 14, 2010 5:48 am

Re: File Upload
Scottie1972
Esky wrote:
Sick! is there anyway you can password is to only allow myself to upload files?
I control my uploads and navigation on all my sites by using SESSIONs. Then by using a SESSION, you can control many feature that you can write into your php script.
Image
4 posts Page 1 of 1
Return to “Tutorials”