?
Solved

Cannot upload file with php!

Posted on 2007-10-13
10
Medium Priority
?
1,261 Views
Last Modified: 2008-01-09
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?
0
Comment
Question by:nobodynowherenothing
  • 5
  • 4
10 Comments
 
LVL 1

Author Comment

by:nobodynowherenothing
ID: 20072365
By the way guys, Yes uploading files is on in php.ini ... and i have restarted the web server after enabaling it ..
0
 
LVL 21

Expert Comment

by:nizsmo
ID: 20072371
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
 
LVL 20

Expert Comment

by:steelseth12
ID: 20072373
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:nobodynowherenothing
ID: 20072381
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
 
LVL 20

Expert Comment

by:steelseth12
ID: 20072385
it is supposed to display the form again ....  and under the form a notice "File uploaded successfully".
0
 
LVL 1

Author Comment

by:nobodynowherenothing
ID: 20072388
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
 
LVL 1

Author Comment

by:nobodynowherenothing
ID: 20072389
@steelseth12:

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

hmm
0
 
LVL 20

Accepted Solution

by:
steelseth12 earned 2000 total points
ID: 20072395
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
 
LVL 1

Author Comment

by:nobodynowherenothing
ID: 20072403
@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
 
LVL 20

Expert Comment

by:steelseth12
ID: 20072409
Glad i could help :)
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to implement server side field validation and display customized error messages to the client.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses
Course of the Month16 days, 23 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question