Babu Ahmed
Babu Ahmed

Reputation: 121

Php file is not uploading to folder

I've a html upload form. It's working in my Localhost. But It's not working on live sever. It's insert the information to db but not uploading the file to folder called "photos".

Php code:

$upload_path = "photos/";
$upload = mysql_query("INSERT INTO photos (photo_cap, photo_name, photo, date) 
VALUES('$title','$filenameuniq', '$file', '$uploadate')");

        if($upload)
        {                       
            if(!empty($file))
            {
                if(!move_uploaded_file($_FILES['file']['tmp_name'], $upload_path . $filenameuniq))
                {
                echo '<pre>Your file was not uploaded please try again here are your debug informations:'.print_r($_FILES) .'</pre>';                   
                }                   
            }//// upload to folder  

            echo "<font color=green>Successfully Updated.</font>";
            header("Refresh:2; url=allphotos.php");
            exit(); 
        }

Debug:

Array ( [file] => Array ( [name] => Blue hills.jpg [type] => image/jpeg [tmp_name] => 
C:\Windows\Temp\php95FB.tmp [error] => 0 [size] => 28521 ) )

Your file was not uploaded please try again here are your debug informations:1

Why it's not uploading to "photos" folder ? On server how it's show C:\Windows ?

Upvotes: 1

Views: 164

Answers (2)

Madan Singh
Madan Singh

Reputation: 199

Put validate for size, and type. then check it..

Upvotes: 0

Arun Killu
Arun Killu

Reputation: 14263

I think the problem is with max file size

Value: 1; The uploaded file exceeds the upload_max_filesize directive in php.ini.

change the value to some higher value in php.ini.safer way is to reduce restrict the max upload size to 2mb

Upvotes: 1

Related Questions