2010-01-09 90 views
1

嗨,我使用这个class.upload.php为我的项目,我必须说这是非常有益的。 但是我坚持这个错误class.upload.php获取错误

没有正确上传的源文件。无法在过程 携带

任何人都可以指导我如何解决issue.Thanks 这里就是我认为错误lies..thanks

<?php 
require_once('class.upload.php'); 
if((isset($_POST['step']))&&($_POST['step']=='process')){ 
    $pictime = strtotime(date('Y-m-d H:i:s')); 
    $pic = "picture"; 

    $id = $_POST['id']; 

    $category = $_POST['category']; 
    $username = $_POST['username']; 
    $path = $_SERVER['DOCUMENT_ROOT'].$_POST['tempfile']; 
    //connect to the server 
    $conn = mysql_connect('localhost','root',''); 
    if(!$conn) 
    { 
    echo "Could not connect to the server"; 
    } 

    //connect to the database 
    $db = mysql_select_db("enzeon_db" , $conn); 
    if(!$db) 
    { 
    echo "Could not connect to the database"; 
    } 

    //query the database to get the imagepath and the thumbpath 
    $query = "SELECT * FROM machine_db WHERE id = '$id' and m_category = '$category' and username = '$username'"; 

    $result = mysql_query($query) or die("Some error occured" . mysql_error()); 

    $num = mysql_num_rows($result); 
    if($num == 1) 
    { 
    $row = mysql_fetch_array($result); 
    $imagepath = $row['m_imagepath']; 

    $imagethumb = $row['m_thumb_path']; 

    } 


    $handle = new Upload($_SERVER['DOCUMENT_ROOT'].$_POST['tempfile']); 

    if ($handle->uploaded) { 

    $handle->file_src_name_body  = $pic; // hard name 
    $handle->file_new_name_body = 'enzeon_'.$pictime; 

    $handle->file_overwrite = false; 
    $handle->file_auto_rename = false; 
    $handle->image_resize   = true; 
    $handle->file_src_pathname = true; 
    $handle->image_x     = 200; //size of final picture 
    $handle->image_y     = 200; //size of final picture 

    $handle->jcrop     = true; 
    $handle->rect_w     = $_POST['w']; 
    $handle->rect_h     = $_POST['h']; 
    $handle->posX     = $_POST['x']; 
    $handle->posY     = $_POST['y']; 
    $handle->jpeg_quality  = 100; 
    $handle->Process($_SERVER['DOCUMENT_ROOT'].'/LoginSystem/upload_pic/'); 

    //thumb-50 
    $handle->file_src_name_body  = $pic; // hard name 
    $handle->file_new_name_body = 'idrish_'.$pictime; 
    $handle->file_overwrite = false; 
    $handle->file_auto_rename = false; 
    $handle->image_resize   = true; 
    $handle->image_x     = 100; 
    $handle->image_y     = 100; //size of picture 

    $handle->jcrop     = true; 
    $handle->rect_w     = $_POST['w']; 
    $handle->rect_h     = $_POST['h']; 
    $handle->posX     = $_POST['x']; 
    $handle->posY     = $_POST['y']; 
    $handle->jpeg_quality  = 100; 
    $handle->Process($_SERVER['DOCUMENT_ROOT'].'/LoginSystem/upload_pic/'); 
    if($handle->processed) 
    { 
    echo "gimme some sunshine"; 
    } 
    else 
    { 
    echo 'error' . $handle->error; 
    } 



    $handle->clean(); 

    } 
    else { 

    echo "here" . $handle->error; 
    } 

} 
echo "yes"; 
    //header("location:".$_SERVER["PHP_SELF"]); 
?> 

回答

0
$handle = new Upload($_SERVER['DOCUMENT_ROOT'].$_POST['tempfile']); 

它应该代码是

$handle = new Upload($_SERVER['DOCUMENT_ROOT'].$_FILES['tempfile']); 

只是这样做print_r($_POST);print_r($_FILES);,你会明白为什么

+0

只要'$ handle =新上传($ _ FILES ['tempfile']);' – VolkerK 2010-01-09 13:14:13

+0

@antpaw感谢您的回复。但我从另一个文件调用tempfile路径,所以$ _POST我认为是正确的。另外print_r($ _ FILES)给出一个空数组。我也尝试把echo $ handle-> log;在我的代码,并得到了以下输出,错误“没有正确的上传的源文件。不能进行一个过程”你能建议别的什么......这让我疯狂... – noobcode 2010-01-09 13:57:40

+1

也许你的表单标记缺失enctype = “多部分/格式数据” – antpaw 2010-01-09 14:42:27