-
Notifications
You must be signed in to change notification settings - Fork 42
Open
Description
Seems that the lib keep the original file name and there is no way that the server can tell ng-flow the new file name, my server output this on complete:
{
"success":true,
"flowTotalSize":58110,
"flowIdentifier":"10152987551505362-2e68232139983ba857669baf3c2d45c7_development.jpg-58110",
"flowFilename":"4498b3d20302c1c3b75ce37c1e5fefac",
"flowRelativePath":"http:\/\/localhost\/images\/users\/4498b3d20302c1c3b75ce37c1e5fefac"
}my upload script:
<?php
$path = __DIR__ . '/../public/images/users/';
$tmp = __DIR__ . '/../tmp/';
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$chunkDir = $tmp . DIRECTORY_SEPARATOR . $_GET['flowIdentifier'];
$chunkFile = $chunkDir.'/chunk.part'.$_GET['flowChunkNumber'];
if (file_exists($chunkFile)) {
header("HTTP/1.0 200 Ok");
} else {
header("HTTP/1.0 404 Not Found");
}
}
// $file = $path . (isset($_FILES['file']) ? $_FILES['file']['name'] : $_GET['flowFilename']); // this is using original name, but in this case the file sooner or later will be overrite by other user that upload a file with the same name
$file = $path . md5(time()); // The way I want, it need to add the extension but it was a test only
if (isset($_FILES)) {
copy($_FILES['file']['tmp_name'], $file);
echo json_encode([
'success' => true,
//optional
'flowTotalSize' => $_FILES['file']['size'],
'flowIdentifier' => $_FILES['file']['name'] . '-' . $_FILES['file']['size'],
'flowFilename' => basename($file),
'flowRelativePath' => 'http://localhost/images/users/' . basename($file)
]);
} else {
if (\Flow\Basic::save($file, $tmp)) {
echo json_encode([
'success' => true,
//optional
'flowTotalSize' => $_GET['flowTotalSize'],
'flowIdentifier' => basename($file),
'flowFilename' => basename($file),
'flowRelativePath' => 'http://localhost/images/users/' . basename($file)
]);
}
}Metadata
Metadata
Assignees
Labels
No labels