Cannot upload file with php!

Hi guys,

Write so i have a linux server - its running Centos 5.X with apache2! No firewalls as long as im aware of ... However i cannot upload ANY files to the server .. yes i am aware of the file limits in the php.ini but i cannot even upload 1k files with simplest example such as the one here :

http://www.developertutorials.com/tutorials/php/upload-files-php-050620/page1.html

The folder is created, it is 777 but still nothing!

What am i doing wrong?
LVL 1
nobodynowherenothingAsked:
Who is Participating?
 
steelseth12Commented:
No you got an error code.

UPLOAD_ERR_NO_TMP_DIR

Value: 6; Missing a temporary folder. Introduced in PHP 4.3.10 and PHP 5.0.3.
0
 
nobodynowherenothingAuthor Commented:
By the way guys, Yes uploading files is on in php.ini ... and i have restarted the web server after enabaling it ..
0
 
nizsmoDeveloperCommented:
Are you sure you have modified the right php.ini? Sometimes there can be multiple php.ini's.

Also does the script output any error at all?

Let me know how you go.
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
steelseth12Commented:
try this

<form enctype="multipart/form-data" action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="2048000">
File: <input name="userfile" type="file" /><br />
<input type="submit" value="Upload" />
</form>

<?php
if (@is_uploaded_file($_FILES["userfile"]["tmp_name"])) {
copy($_FILES["userfile"]["tmp_name"], "images/" . $_FILES["userfile"]["name"]);
echo "<p>File uploaded successfully.</p>";
}
?>

Note: this will move the file to the folder images ... if it does not exist either create it or change the script to the directory of your liking
0
 
nobodynowherenothingAuthor Commented:
Hello,

@ nizsmo:

Right yeah i did :

dns28:/var/www/virtual/shababi.net/htdocs# locate php.ini
/etc/php5/apache2/php.ini
/etc/php5/cli/php.ini


And as you can see there is only 2 files and i maked sure in both php upload is on and restarted the web server ..

Been working on this since the morning .. really out of ideas ... Also i do not get any errors ...

@steelseth12

Ok i tried that .. the folder is created permission is 777 when i select a file and press upload .. the page reloads and comes back to the form so from my underestanding

if (@is_uploaded_file($_FILES["userfile"]["tmp_name"])) {

It is not set so it displayes the form again ...

Thanks for responses
0
 
steelseth12Commented:
it is supposed to display the form again ....  and under the form a notice "File uploaded successfully".
0
 
nobodynowherenothingAuthor Commented:
Ok guys got more information so i did :

print_r($_files);

and  now i get:

Array ( [userfile] => Array ( [name] => CV.docx [type] => [tmp_name] => [error] => 6 [size] => 0 ) )

So the file has been uploadded right?

0
 
nobodynowherenothingAuthor Commented:
@steelseth12:

Yeah but no notice .. and as i check in the folder no file ...

hmm
0
 
nobodynowherenothingAuthor Commented:
@steelseth12:

Your awsome thank you! Went into php.ini and i setup a temp folder and its working now!

Wow such a reliefe .. Thank you
0
 
steelseth12Commented:
Glad i could help :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.