自动获取文件路径

时间:2011-02-23 11:39:44

标签: file-upload

我正在寻找一种自动上传文件但跳过浏览并选择文件过程的方法。

所以我通过表单以某种方式设置文件的位置,客户端只需单击提交,它将自动从我设置的路径上传文件。跳过浏览文件进程。

我想将它集成到以下不受欢迎的S3 Class

http://undesigned.org.za/2007/10/22/amazon-s3-php-class/documentation

<?php

    S3::setAuth(awsAccessKey, awsSecretKey);

    $bucket = "upload-bucket";
    $path = "myfiles/"; // Can be empty ""

    $lifetime = 3600; // Period for which the parameters are valid
    $maxFileSize = (1024 * 1024 * 50); // 50 MB

    $metaHeaders = array("uid" => 123);
    $requestHeaders = array(
        "Content-Type" => "application/octet-stream",
        "Content-Disposition" => 'attachment; filename=${filename}'
    );

    $params = S3::getHttpUploadPostParams(
        $bucket,
        $path,
        S3::ACL_PUBLIC_READ,
        $lifetime,
        $maxFileSize,
        201, // Or a URL to redirect to on success
        $metaHeaders,
        $requestHeaders,
        false // False since we're not using flash
    );

    $uploadURL = "https://{$bucket}.s3.amazonaws.com/";

?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>S3 Form Upload</title>
</head>
<body>
    <form method="post" action="<?php echo $uploadURL; ?>" enctype="multipart/form-data">
<?php
    foreach ($params as $p => $v)
        echo "        <input type=\"hidden\" name=\"{$p}\" value=\"{$v}\" />\n";
?>
        <input type="file" name="file" />&#160;<input type="submit" value="Upload" />
    </form>
</body>
</html>

它在什么时候抓取文件路径?

是不是在这里抓住它的名字

我可以用$ _FILES ???

做点什么

有人可以给我一个关于从哪里开始的观点,我会真的很喜欢这个。

感谢

1 个答案:

答案 0 :(得分:1)

您必须指定交易工具。常见的html表单没有这样的功能。

您可以尝试使用value =“c:\ somefile.ext”,但许多浏览器都不接受此操作。