1

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 ?

6
  • 1
    Have you enough permission for file upload? Commented Feb 25, 2013 at 6:24
  • Check the path and permission Commented Feb 25, 2013 at 6:25
  • I didn't see that. what is the permission for upload a file ? is it only write, read ? Commented Feb 25, 2013 at 6:25
  • Why is your file is uploaded to C:\Windws\Temp? Shouldn't it be uploaded at C:\Users\UserName\...? Check if you have the rights to write into the directory. Commented Feb 25, 2013 at 6:26
  • @tftd I'm checking it.. Commented Feb 25, 2013 at 6:28

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

3 Comments

file_uploads = On upload_max_filesize = 2M max_file_uploads = 20
check my uploaded file size in php.ini file.
change that to 3M since you are uploading a file of 2.8 mb size then restart Apache then try again
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.