Page 1 of 1

File upload doesnt work at all

Posted: Sat Feb 14, 2004 7:45 pm
by EGNJohn
Fill upload with php doesnt work at all. In the php.ini upload is turned on.

I changed the max upload from 2m to 20m in php.ini thru ssh. Restarted apache and rebooted server, still nothing uploads at all not even a 5k pic.

running:
Apache 1.3.29
PHP 4.3.3

Posted: Sat Feb 14, 2004 10:20 pm
by Tanus
Have you got the enctype set for the form?

Posted: Sat Feb 14, 2004 10:45 pm
by m3mn0n
Post code.

Posted: Sat Feb 14, 2004 10:55 pm
by Illusionist
If you just got he script from somewhere and apsted into a php file and saved it, then ya chances are its nto goign to work. 99.9% of the time there will be something int he code that has to be changed to fit your need, or requirements. So its probably nothing with PHP or your server, but more witht he code, so do as Sami said and post some code for us to check.

Posted: Sun Feb 15, 2004 7:05 am
by EGNJohn
The problem isnt just forum upload its all upload script. This is a script I made to test upload after making changes to max upload size.
<?php


if (!$_POST['submit'])
{
echo $_SERVER['DOCUMENT_ROOT'];
echo "<form action=quickload.php enctype=\"multipart/form-data\ method=\"POST\">
<input type='file' name='file'>
<input type='submit' name='submit' value='Submit'>
</form>";

}

else
{
if (!copy($_FILES['file']['tmp_name'] , "/home/accelera/public_html/files"))
{
echo "Failure!";
}


}


?>

Posted: Sun Feb 15, 2004 7:19 am
by Illusionist
try doing this:

Code: Select all

$dir = $_SERVER['DOCUMENT_ROOT'] . "/home/accelera/public_html/files";
if (!copy($_FILES['file']['tmp_name'] , $dir))

Posted: Sun Feb 15, 2004 7:53 am
by EGNJohn
when using that code, after clicking submit button browser url changes to include the origional path the uploaded file was taken from on harddrive.
here is the script in action http://acceleratedhosting.com/files/quickload2.php


PS: If it means anything, this is on a new dedicated server. (just got it 2 days ago) Is it possible that when it was set up they didnt load something correctly.

Posted: Sun Feb 15, 2004 9:25 am
by DuFF
Hmmm.

In your form you are using POST but when I used the script mentioned above it was using GET. Whats up with that?

Anyway, I also got an Undefined Index error, so I would suggest that you do this:

EDIT: I think I just realized your error. In the COPY function, you were just specifying a path. You need to specify the path AND the filename. Try something like this:

Code: Select all

<?php


if ($_POST['submit'] == "Submit")
{
    $uploaddir = "/home/accelera/public_html/files/" . $_FILES['file']['name'];  //Notice the addition of the filename
    $tempdir = $_FILES['file']['tmp_name'];

    if (!move_uploaded_file($tempdir, $uploaddir ))
    {
         echo "Failure!";
    }
    else
    {
         echo "Success!";
    }
}

else
{
echo $_SERVER['DOCUMENT_ROOT'];
echo "<form action=quickload.php enctype="multipart/form-data\ method="POST">
<input type='file' name='file'>
<input type='submit' name='submit' value='Submit'>
</form>";
}

?>

Posted: Mon Feb 16, 2004 6:55 pm
by EGNJohn
Thanx duff, The code works on my virtual server account, but still no uploads work on the new dedicated server.

I would have to assume that there is a problem with the setup on the dedicated server. What do you think?