开发者

Automatically grab file path

开发者 https://www.devze.com 2023-02-13 02:31 出处:网络
Everyone i am looking for a way to automatically upload a file but skip the browse and choose file process.

Everyone i am looking for a way to automatically upload a file but skip the browse and choose file process.

So i set the location of the file somehow via the form and the client just has to click submit and it will automatcially upload the file from the path i have set. skipping the browse for file process.

I would like to intergrate it into the following undesigns 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"&开发者_如何学Pythongt;
<?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>

at what point does it grab the file path ?

is it grabbing it out of the name here

can i do something with $_FILES ???

Can someone please give me a point on where to start i would really appriciate this.

thanks


You'll have to specify the tools of the trade. A common html form has no such functionality.

You can try value="c:\somefile.ext" but many browsers will not accept this.

0

精彩评论

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