0
<?php
session_start();
if($_SESSION['user']!=true)
{
    header('Location:login.php');
}
$error="";
?>

<?php
include("include/databaseq.php");

$title=$_POST['title'];
$date=$_POST['date'];
$description=$_POST['description'];


    function GetImageExtension($imagetype)
     {
       if(empty($imagetype)) return false;
       switch($imagetype)
       {
           case 'image/bmp': return '.bmp';
           case 'image/gif': return '.gif';
           case 'image/jpeg': return '.jpg';
           case 'image/png': return '.png';
           default: return false;
       }
     }
if (!empty($_FILES["uploadedimage"]["name"])) {
    $file_name=$_FILES["uploadedimage"]["name"];
    $temp_name=$_FILES["uploadedimage"]["tmp_name"];
    $imgtype=$_FILES["uploadedimage"]["type"];
    $ext= GetImageExtension($imgtype);
    $imagename=date("d-m-Y")."-".time().$ext;
    $target_path = "/images/news/".$imagename;
if(move_uploaded_file($temp_name, $target_path)) {

    $query_upload="INSERT into recent_news (title,date,description,images_path,submission_date) VALUES

('$title','$date','$description','".$target_path."','".date("Y-m-d")."')";
    mysql_query($query_upload) or die("error in $query_upload == ----> ".mysql_error()); 

?>
        <script>
  alert("News Updated");  


  window.location="recent_news.php";
    </script>    

    <?php    

}

else{
   exit("Error While uploading image on the server");
}
}
?>
3
Contributors
3
Replies
13
Views
3 Years
Discussion Span
Last Post by veedeoo
0

My image upload function is working on local but not in Live.. This is the code
Please help me out

1

You can simply do a simple test.

Check for the upload directory permission

<?php

    echo substr(sprintf('%o', fileperms('/images/news/')), -4);

check for the file upload settings on your php.ini file can also be done this way

echo 'Maximum File Upload allowed: '. (ini_get('upload_max_filesize')) .'<br/>';
echo 'Post Max Size Setting: '. (ini_get('post_max_size')) .'<br/>';
echo 'Server Memory Setting:'. (ini_get('memory_limit')) .'<br/>';

You combine those codes above will pretty much give you the answers.

Edited by veedeoo: more info added

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.