开发者

Can PHP web app. open or list a folder in a client machine

This is my first question on stackflow, my favourite script helper. I have a project that requires interaction with the clients machine to get the contents of a folder, usually scanned images. They are used to search my web app for a match of the image then retrieve the 开发者_运维技巧user information. however, I have seen post that said that can only be achieved through Java applet or ActiveX. how can I achieve this considering am developing with PHP/MYSQL.

please anybody with suggestion or guide should help pls...


Can you clarify? Do you want the user to be prompted with a 'browse for file' pop-up or do you want the file to be open/read automatically? Here is some code you can use if you want to have a 'browse for file' window popping up:

$ok = validFile($_FILES['uploaded']);
    $uploaded_type = $_FILES['uploaded']['type'];
    $uploaded_size = $_FILES['uploaded']['size'];

    if($ok==0)
        echo 'Sorry. Your file was not uploaded.';
    else
    {
        //inserting file data into DB
        $qry = mysql_query("INSERT INTO $table_name (mime, size, created)
            VALUES ('$uploaded_type', '$uploaded_size', NOW())");

        if(!$qry)
        {
           die('Error: ' . mysql_error() . '<br />');
           $ok = 0;
        }

        //updated uniqueID for file
        $filename = explode(".", basename($_FILES['uploaded']['name']));
        $idq = mysql_insert_id();
        $mapName = $filename[0] . $idq . '.' . $filename[1];
        $target = "upload/"; 
        $target = $target . $mapName;

        $qry = mysql_query("UPDATE $table_name SET uniquename='$mapName', path='$target' WHERE id='$idq'");

        if (!$qry)
            die("FAIL: " . mysql_error());

        //uploading file
        if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target) && $ok == 1) 
        {
            echo "The file ". $filename[0] . "." . $filename[1] . " has been uploaded";
        } 
        else 
            echo "Sorry, there was a problem uploading your file.";
    }
}
?>

<form enctype="multipart/form-data" action="upload.php" method="POST">
 Please choose a file: <input name="uploaded" type="file" /><br />
 <input type="submit" value="Upload" />
</form> 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜