i am a newbie with php and html......i really need a file upload button on my website and the instructions on how to make it work. I have found many that give the html code for the forum and the php that runs it, but none of the tutorials give enough detailed description on where to save the php and html to make them work together etc.
Please Help!!
-Brian
File Upload Wont work
Moderator: General Moderators
Code: Select all
<form enctype="multipart/form-data" action="_URL_" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
Send this file: <input name="userfile" type="file" />
<input type="submit" value="Send File" />
</form>Code: Select all
<?php
// In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead
// of $_FILES.
$uploaddir = '/var/www/uploads/';
$uploadfile = $uploaddir . $_FILES['userfile']['name'];
print "<pre>";
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
print "File is valid, and was successfully uploaded. ";
print "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);
}
print "</pre>";
?>-
maverickbce8
- Forum Newbie
- Posts: 7
- Joined: Sun May 14, 2006 10:56 pm
stick that & the form in your text editor, save as upload.php (or whatever you want), and then upload that page to a php enabled webserver. =]
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Put this in a file named upload.php
And then read the PHP manual. Available in my signature below.
Change $uploaddir = '/var/www/uploads/'; to the folder you want the pictures to go. Make sure it's permissions are set to 0777.
Code: Select all
<?php
// In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead
// of $_FILES.
$uploaddir = '/var/www/uploads/';
$uploadfile = $uploaddir . $_FILES['userfile']['name'];
print "<pre>";
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
print "File is valid, and was successfully uploaded. ";
print "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);
}
print "</pre>";
?>
<form enctype="multipart/form-data" action="_URL_" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
Send this file: <input name="userfile" type="file" />
<input type="submit" value="Send File" />
</form>Change $uploaddir = '/var/www/uploads/'; to the folder you want the pictures to go. Make sure it's permissions are set to 0777.
-
maverickbce8
- Forum Newbie
- Posts: 7
- Joined: Sun May 14, 2006 10:56 pm