2011-02-23 47 views
1

每個人我都在尋找一種方法來自動上傳文件,但跳過瀏覽並選擇文件進程。自動抓取文件路徑

所以我通過表單以某種方式設置文件的位置,客戶端只需點擊提交,它就會自動從我設置的路徑上傳文件。跳過瀏覽文件進程。

我想將其分類:G642.44成以下undesigns S3級

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什麼???

有人請給我一點從哪裏開始我真的appriciate這一點。

謝謝

+0

提供更多的細節(什麼平臺,語言等)你想解決方案的工作..此外,一些相關的代碼片段以及.. – TheCottonSilk 2011-02-23 11:41:53

+0

我已經重新編輯的問題。 – iSimpleDesign 2011-02-23 12:02:44

回答

1

您必須指定交易工具。一個常見的html表單沒有這樣的功能。

你可以嘗試value =「c:\ somefile.ext」,但很多瀏覽器都不會接受這個。

+0

對不起,我是超級vage與我重新編輯它的問題 – iSimpleDesign 2011-02-23 11:45:52