Rank: Newbie
Groups: Member
Joined: 6/4/2013(UTC) Posts: 6
|
I am trying to get the full file path and name for an upload, in a JS variable. I am using setAfterPackageUpload to create a JavaScript function that will populate input fields based on the upload, which need to have the full URL of the upload. I cannot figure out how to get a JavaScript variable for the upload full file name. Thanks
|
|
|
|
Rank: Advanced Member
Groups: Administration
Joined: 12/19/2012(UTC) Posts: 164
Was thanked: 8 time(s) in 8 post(s)
|
Hello fbtech, I think you should choose other way to send additional information to server, that better than to use client-side events. You can find out how to upload additional data here: http://www.aurigma.com/d...onal-data-in-php-iuf.htm For example, you can send it like here: Sending data: Code:
<form id="addForm" name="addForm">
<input ID="fullUrl" name="fullUrl" type="text" value="http://domain.name/Files/image.jpg" />
</form>
<?php
require_once "ImageUploaderFlashPHP/ImageUploaderFlash.class.php";
$uploader = new ImageUploaderFlash("Uploader1");
$uploader->getUploadSettings()->setActionUrl("upload.php");
$uploader->getMetadata()->setAdditionalFormName("addForm");
$uploader->render();
?>
Receiving sent data: Code:
<?php
require_once "ImageUploaderFlashPHP/UploadHandler.class.php";
function saveAllUploadedFiles($uploadedFiles) {
$packageFields = $uploadedFiles[0]->getPackage()->getPackageFields();
$fullUrl = $packageFields["fullUrl"];
}
$handler = new UploadHandler();
$handler->setAllFilesUploadedCallback("saveAllUploadedFiles");
$handler->processRequest();
?>
|
Best regards, Vitaly Kustov Aurigma Technical Support
|
|
|
|
Rank: Newbie
Groups: Member
Joined: 6/4/2013(UTC) Posts: 6
|
I understand that, but what I need is to get the full URL without having to reload the page, I need it to populate a field client-side, without having to get it in a PHP script, which would be server-side. Is this possible?
|
|
|
|
Rank: Newbie
Groups: Member
Joined: 6/4/2013(UTC) Posts: 6
|
In your response, Code:
$fullUrl = $packageFields["fullUrl"];
is "fullUrl" the ID or name of the input field?
|
|
|
|
Rank: Newbie
Groups: Member
Joined: 6/4/2013(UTC) Posts: 6
|
I'm not sure if I'm clear, but I need the fields to be populated automatically based off of the full URL. Not having to enter it in.
|
|
|
|
Rank: Newbie
Groups: Member
Joined: 6/4/2013(UTC) Posts: 6
|
If I can get the PHP variable for the upload, I got it to work as an Ajax call.
|
|
|
|
Rank: Advanced Member
Groups: Administration
Joined: 12/19/2012(UTC) Posts: 164
Was thanked: 8 time(s) in 8 post(s)
|
Hello, Quote:In your response, $fullUrl = $packageFields["fullUrl"]; is "fullUrl" the ID or name of the input field? This is a name of the input field. I just written a sample, where you can get a name of uploaded files. So you can get a full URL for uploaded files: Code:
<?php
require_once '../ImageUploaderFlashPHP/ImageUploaderFlash.class.php';
$url = "http://myDomain.Name/";
$galleryPath = 'UploadedFiles/';
?>
<script>
function BeforeUpload () {
// Site Url
var url = '<?php echo $url ?>';
// Gallery Path
var galleryPath = '<?php echo $galleryPath ?>';
// Get uploader
uploader = $au.imageUploaderFlash('Uploader1');
for(var i = 0; i < uploader.files().count(); i++)
{
// Get fileName
value = uploader.files().get(i).name();
alert("File full url: " + url + galleryPath + value);
}
}
</script>
<?php
// create uploader object
$uploader = new ImageUploaderFlash('Uploader1');
$uploader->getClientEvents()->setBeforeUpload("BeforeUpload");
// .. other settings
// render uploader markup
$uploader->render(); ?>
The solution doesn't require ajax or execute php script twice. I hope it help. |
Best regards, Vitaly Kustov Aurigma Technical Support
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.