PHPクラスについてサポートが必要です。私はそれがどのように機能するかについての知識が限られており、それについてもっと発見しようとしています。その間に、クラス内でこれらの関数を実行した後に変数を取得する必要があるという問題があります。
protected function upcount_name_callback($matches) {
$index = isset($matches[1]) ? intval($matches[1]) + 1 : 1;
$ext = isset($matches[2]) ? $matches[2] : '';
return ' ('.$index.')'.$ext;
}
protected function upcount_name($name) {
return preg_replace_callback(
'/(?:(?: \(([\d]+)\))?(\.[^.]+))?$/',
array($this, 'upcount_name_callback'),
$name,
1
);
}
次のJSステートメントでこの変数を取得し、INSERTphpファイルに送信する必要があります。
$('#albumBack.fileupload').bind('fileuploaddone',function(e,data) {
//Loop through each page and return object and write to DB
$.each(data.files, function (index, file) {
var filename = file.name;
$.ajax({
type: "POST",
url: "../albumUploader/queries/albumPages.php",
data: {file: filename}
});
});
});
現在取得しているファイル名は、追加された名前ではなく、元の名前です。これについて助けてくれてありがとう。
albumPages.php
//Variables for gallerimage table
$originalName = $_POST['file'];
$clientRef = $_SESSION['clientRef'];
$galleryID = $_SESSION['newGalleryId'];
$galleryLayout = $_SESSION['layoutID'];
$imageID = rand();
//Find the sort# for the gallery
$qSortOrder = mysql_query("SELECT MAX(sort) AS sortOrder
,id
,clientRef
,galleryId
FROM galleryimage
WHERE galleryId='{$galleryID}'
AND clientRef= '{$clientRef}'
");
$fsortOrder = mysql_fetch_array($qSortOrder);
//Latest revision
$orderNumber = $fsortOrder['sortOrder'];
$order = $orderNumber + 1;
$query = "INSERT INTO galleryimage
(
galleryId
,image
,OrgImageName
,clientRef
,sort
,layout
) VALUES (
'{$galleryID}'
,'{$imageID}'
,'{$originalName}'
,'{$clientRef}'
,'{$order}'
,'{$galleryLayout}'
)";
$return = mysql_query($query);
$ originalNameは、img.jpg、$ img(1).jpgなどとして定義する必要のある$変数です。私はPOSTファイルであり、入力から選択された元のファイルになります。
これは、ファイルを選択するフォームです。
<form class="fileupload" id="albumBack" action="../js/jQuery-file-upload/server/php/" method="POST" enctype="multipart/form-data" >
<!-- The fileupload-buttonbar contains buttons to add/delete files and start/cancel the upload -->
<div class="row fileupload-buttonbar">
<span class="btn btn-success fileinput-button">
<span>Choose Back</span>
<input type="file" name="files[]">
</span>
</div>