Page 1 of 1

Uploading Files

Posted: Wed Nov 02, 2005 10:28 am
by elecktricity
This dosnt seem to work right...

add.php

Code: Select all

<form enctype=\'image/gif\' action=\'add2.php\' method=\'POST\'>
    <input type=\'hidden\' name=\'MAX_FILE_SIZE\' value=\'70000\' />
    Send this file: <input class=\'text\' name=\'userfile\' type=\'file\' />
    <input class=\'text\' type=\'submit\' value=\'Send File\' />
</form>

add2.php

Code: Select all

<?php
$uploaddir = '/home/rootbee/public_html/vividgamers/iconrush/icons/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
echo '<pre>';
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo 'Success';
} else {
echo 'Failure';
}

print "</pre>";

?>
keeps saying going to the else and saying failure... not sure whats going wrong

Posted: Wed Nov 02, 2005 10:35 am
by Skittlewidth
I think the enctype has to be "multipart/form-data", even if its just images you're uploading.

Posted: Wed Nov 02, 2005 3:33 pm
by foobar
Skittlewidth wrote:I think the enctype has to be "multipart/form-data", even if its just images you're uploading.
Yep. This is compulsory for file uploads. Otherwise, it won't be sent correctly.

Posted: Wed Nov 02, 2005 4:50 pm
by elecktricity
I switched it to that and its still doing about the same thing... here is the error...



Code: Select all

Warning:  move_uploaded_file(/home/rootbee/public_html/site1/dir/image.gif): failed to open stream: Permission denied in /home/rootbee/public_html/site1/dir/add2.php on line 5



Warning:  move_uploaded_file(): Unable to move '/tmp/phpwAS0kf' to '/home/rootbee/public_html/site1/dir/image.gif' in /home/rootbee/public_html/site1/dir/add2.php on line 5

Failure

Posted: Wed Nov 02, 2005 5:10 pm
by programmermatt
Apache doesn't have permission to put the file in that directory apperently

Posted: Wed Nov 02, 2005 5:12 pm
by elecktricity
how do I give it permission? I believe the permission is at 777

Posted: Thu Nov 03, 2005 6:27 am
by foobar
elecktricity wrote:how do I give it permission? I believe the permission is at 777
Make the permission of the directory 777 or 666. If this isn't on your comp, than maybe your host has a file-size restriction.