Jep,这就是问题。如何通过这个漂亮的团队处理Fileuplaods?
类似的东西:
$app -> post('/new/', function() use ($app) {
$photo = Model::factory('Photos') -> create();
$unique_id = md5(uniqid(rand(), true));
$WORKSPACE = 'data/photos/';
$media = $HTTP_POST_FILES['photo']['name'];
$filetype = strrchr($media,'.');
$new_upload = $WORKSPACE . $unique_id . $filetype;
$the_upload = copy($HTTP_POST_FILES['photo']['tmp_name'], $new_upload);
$uploaded_file = $new_upload;
@chmod($uploaded_file, 0777);
$photo -> timestamp = date('Y-m-d H:i:s');
$photo -> url = 'data/photos/' . $unique_id . $filetype;
$photo -> new_picture = $unique_id . $filetype;
$photo -> description = $app -> request() -> post('description');
$photo -> save();
$app -> redirect('/upload/');
});
无效,导致:
超薄应用程序错误: 消息:未定义的变量:HTTP_POST_FILES
但是如何访问fileupload字段,如:
<input type="file" name="photo" value="" id="photo" />
通过Slim?