2016-04-23 14 views

Antwort

1

Wenn ich Ihre Frage richtig verstanden habe, musste ich auch die gleiche Funktionalität in meinem Projekt, und das ist, was ich tat,

Dies ist die fileUpload.php

<?php 
$target_path="uploads/".$_POST['username']."/"; 
if (!is_dir($target_path)) 
// is_dir - tells whether the filename is a directory 
{ 
    //mkdir - tells that need to create a directory 
    mkdir($target_path); 
} 
$target_path=$target_path.basename($_FILES['image']['name']); 
try { 
    //throw exception if can't move the file 
    if (!move_uploaded_file($_FILES['image']['tmp_name'], $target_path)) { 
     throw new Exception('Could not move file'); 
    } 
    echo $target_path; 
} catch (Exception $e) { 
    die('Upload Failed: ' . $e->getMessage()); 
} 
?> 

Datei während dieser die Datei Uploads von einem Browser zu testen,

<html> 
    <head> 
     <title>File Upload Form</title> 
    </head> 
    <body> 
     <form enctype="multipart/form-data" action="fileUpload.php" method="POST">    
      <br/>Choose a file to upload: <br/><input name="image" type="file" /><br /> 
      User Name: <input type="text" name="username"/> 
      <input type="submit" value="Upload File" /> 
     </form> 

    </body> 
</html> 

ich glaube, du leicht herausfinden, wie diese von android zu handhaben.

Hoffe, das hilft! :)

+0

@Marc Du solltest die Antwort akzeptieren, wenn es dir geholfen hat und wenn es dein Problem nicht zumindest in den Kommentaren erklärt hat. –