Hello,

PHP file upload script.

Problem: Unable to upload file under ubuntu server.

I have 2 different webservers setup:
1. xampp on usb and my problametic script works.
2. ubuntu server, exact same php script but it wont upload the file.

What i noticed with xampp: <--works
echo "<br>tempFile=>:-". $_FILES['data']['tmp_name'][$x] . "<br>";
result: tempFile=>:-G:\xampp\tmp\php2D.tmp
print_r($imagearray);
Array ( [0] => Array ( [1] => G:\xampp\tmp\php2D.tmp [2] => 1357153942_robinuser_dog.jpg ) )

What i noticed with Ubuntu server:
echo "<br>tempFile=>:-". $_FILES['data']['tmp_name'][$x] . "<br>";
tempFile=>:/tmp/phpzN6e8U <-- looks like the "tmp" extension is missing.
print_r($imagearray);
Array ( [0] => Array ( [1] => /tmp/phpzN6e8U [2] => 1357153182_robinuser_bird.jpg ) )

if the temp file ext is missing how do I fix this??

Any help you can provide would be greatly appreciated

PHP Code:
?PHP
include('connection.php');
?>
<html> 
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<!-- CSS -->
<style type="text/css">
div.color {
  border-width:2px;
  border-style:solid;
  border-color:#black;
  padding: 3 3 3 3px;
  width: 400px;  
  }
</style>
  
  <!--  Java script -->
<script>
$(function(){
    $('#add-file-field').click(function(){
        $("#text").append('<div class="added-field"><input type="file" name="data[]"><input type="image" src="delete.png" class="remove-btn" value="Remove"></div>');
    });
    $('.remove-btn').live('click',function(){
        $(this).parent().remove();
    });
    });
</script>
</head>

<?php
    $imageUserId 
'robinuser';
        
    
$allowedUpload 6;  // number of file the user can upload
    
$allowedExts = array("jpg""jpeg""gif""png");
    
$remove_these = array(' ','`','"','\'','\\','/');
    
$upload_directory 'uploads/'//image upload folder
    
$fileSize 20000;
    
$imagearray=array();     
    
    if(isset(
$_POST['btnsave']))
    {    for(
$x=0$x<count($allowedUpload); $x++)
        {    echo 
"<br>tempFile=>:-"$_FILES['data']['tmp_name'][$x] . "<br>";
            if(!empty(
$_FILES['data']['name'][$x]))
            {    
$extension end(explode("."$_FILES['data']['name'][$x]));
                if (((
$_FILES["data"]["type"][$x] == "image/gif")
                    || (
$_FILES["data"]["type"][$x] == "image/jpeg")
                    || (
$_FILES["data"]["type"][$x] == "image/png")
                    || (
$_FILES["data"]["type"][$x] == "image/pjpeg"))
                    && (
$_FILES["data"]["size"][$x] < $fileSize)
                    && 
in_array($extension$allowedExts))
                {    if (
$_FILES["data"]["error"][$x] > 0)
                    {    echo 
"Error: " $_FILES["data"]["error"][$x] . "<br>"; }
                    else
                    {    
//Sanitize the filename 
                        
$sanitizedName str_replace($remove_these''$_FILES['data']['name'][$x]);
                        
$newImageName time()."_".$imageUserId."_".$sanitizedName;
                        
//move_uploaded_file($_FILES['data']['tmp_name'][$x], $upload_directory . $newImageName);
                        
if(!empty($newImageName))
                        {    
$imagearray[$x][1] = $_FILES['data']['tmp_name'][$x];
                            
$imagearray[$x][2] = $newImageName;
                        }                                
                    }
                }
                else
                {    echo 
"Invalid file: ".$_FILES["data"]["name"][$x];  }
            }
// end of IF- if(!empty($_FILES['data']['name'][$x]))
        
// endo for loop
        
print_r($imagearray);
        for(
$y=0$ycount($imagearray); $y++)
        {    
move_uploaded_file($imagearray[$y][1], $upload_directory $imagearray[$y][2]);    
            echo 
$imagearray[$y][1] . " " .$upload_directory $imagearray[$y][2]."<br>";
        }                  
    } 
// end of upload button
?>
<body>
<form enctype="multipart/form-data" action="" method="POST">
       <div class="color">
    Upload:
    <br> - Excepted file formats: ing: JPEG, PNG, & GIF formats.
    <br> - Max number of files you can upload: 6
    <hr>
        <div id="text">
            <div ><input name="data[]" id="file" type="file" multiple="multiple" /></div>
        </div>
        <img src="add.jpg"  id="add-file-field" name="add" style="margin-top:21px;"/> 
        <input type="submit" name="btnsave" value="Upload File" />
    </div>
</form>
</body>
</html>