nobodynowherenothing
asked on
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?
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?
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.
Also does the script output any error at all?
Let me know how you go.
try this
<form enctype="multipart/form-da ta" 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_na me"])) {
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
<form enctype="multipart/form-da
<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
copy($_FILES["userfile"]["
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
ASKER
Hello,
@ nizsmo:
Right yeah i did :
dns28:/var/www/virtual/sha babi.net/h tdocs# 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_na me"])) {
It is not set so it displayes the form again ...
Thanks for responses
@ nizsmo:
Right yeah i did :
dns28:/var/www/virtual/sha
/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
It is not set so it displayes the form again ...
Thanks for responses
it is supposed to display the form again .... and under the form a notice "File uploaded successfully".
ASKER
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?
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?
ASKER
@steelseth12:
Yeah but no notice .. and as i check in the folder no file ...
hmm
Yeah but no notice .. and as i check in the folder no file ...
hmm
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
@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
Your awsome thank you! Went into php.ini and i setup a temp folder and its working now!
Wow such a reliefe .. Thank you
Glad i could help :)
ASKER