File upload doesnt work at all
Moderator: General Moderators
File upload doesnt work at all
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
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
Have you got the enctype set for the form?
Last edited by Tanus on Sun Feb 15, 2004 1:33 am, edited 1 time in total.
-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
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.
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!";
}
}
?>
-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
try doing this:
Code: Select all
$dir = $_SERVER['DOCUMENT_ROOT'] . "/home/accelera/public_html/files";
if (!copy($_FILES['file']['tmp_name'] , $dir))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.
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.
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:
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>";
}
?>