Page 1 of 1

Apache file upload to php Server

Posted: Tue Jan 28, 2014 8:20 pm
by habisravi
I have the following script at my php server. On executing post from my android phone.
A new file is created at "upload/" but with zero size.
i have changed the phpinfo

upload_max_filesize = 20M
post_max_size = 20M

Code: Select all

<?php
$uploaddir = './upload/';
$uploadfile = $uploaddir . basename($_FILES['file']['name']);
if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile)) {
    echo "Upload Sucess.\n";
} else {
    echo "Error";
}
?>

Re: Apache file upload to php Server

Posted: Tue Jan 28, 2014 10:15 pm
by vijayalakshmi
HI,
give uploaded tag as <input type="file" name="profile_image"> and
When give destinationation path fully, it will move to uploaded files to the dir(upload folder) as

Code: Select all

<?php
$destination_path = getcwd().DIRECTORY_SEPARATOR;
$uploadfile = $destination_path ."upload/". basename( $_FILES['profile_image']['name']);

if (move_uploaded_file($_FILES['file']['profile_imagee'], $uploadfile)) {
    echo "Upload Sucess.\n";
} else {
    echo "Error";
}
?>
It will work, check it...


pickle | Please use [ syntax=php ], [ syntax=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.

Re: Apache file upload to php Server

Posted: Wed Jan 29, 2014 2:13 pm
by pickle
What does $_FILES['file']['error'] contain? That might be giving you an error.