I tried to follow this code - confused
这是我上传的代码。我不确定在选择文件后在何处/如何包含jquery代码以启用按钮。我试过复制示例并对其进行测试,但我仍然无法使其工作。
HTML
<div id="floatLeft">
<label for="fileToUpload">Select CSV file to Upload:</label>
<input type="file" name="fileToUpload" id="fileToUpload">
</div>
<div id="floatRight">
<input type="submit" value="Generate" name="submit" disabled />
</div>
JQUERY
$(document).ready(
function(){
$('input:file').change(
function(){
if ($(this).val()) {
$('input:submit').attr('disabled',false);
// or, as has been pointed out elsewhere:
// $('input:submit').removeAttr('disabled');
}
}
);
});
答案 0 :(得分:1)
您的代码似乎有效。确保你有:
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
在你的head标签内,你的JQuery在脚本标签内。
答案 1 :(得分:0)
以前的答案对于较小的文件上传看起来很糟糕,因为 #Staging Storage Resource Group Name
$stageSAN = Get-AzResource -Name $stagestorageaccountname -ResourceType "Microsoft.Storage/storageAccounts"
$stagestorageaccountnameRG = $stageSAN.ResourceGroupName
#Restoring the Backup to Storage
$Restore = Restore-AzRecoveryServicesBackupItem -RecoveryPoint $RP[0] -StorageAccountName $stagestorageaccountname -StorageAccountResourceGroupName $stagestorageaccountnameRG -TargetResourceGroupName $TargetVMRGName
#Restore Job Status
$restorejob = Get-AzRecoveryServicesBackupJob -Job $Restore -VaultId $VMRSVVaultID
if ($restorejob.Status -like "InProgress" ) {
do {
$CheckStatus = Get-AzRecoveryServicesBackupJob -Job $Restore -VaultId $VMRSVVaultID
$restorejob = $CheckStatus
start-sleep -Seconds 4
}
until ($restorejob.Status -like "Completed" )
}
else {
Write-Output "Restore Job Failed"
}
# Fetching Job Details
$details = Get-AzRecoveryServicesBackupJobDetails -Job $restorejob -VaultId $VMRSVVaultID
$properties = $details.properties
#$storageAccountName = $properties.'Target Storage Account Name'
$containerName = $properties["Config Blob Container Name"]
$templateBlobURI = $properties["Template Blob Uri"]
Write-Output $templateBlobURI
$BlobURI = $templateBlobURI -Split '/'
$Blob = $BlobURI[4]
#Setting Storage Account Context
Set-AzCurrentStorageAccount -Name $stagestorageaccountname -ResourceGroupName $VMRGname
#Building the Temaplate URI for deploying the server
$templateBlobFullURI = New-AzStorageBlobSASToken -Container $containerName -Blob $Blob -Permission r -FullUri
#Deplaying the Azure VM from Backup
New-AzResourceGroupDeployment -ResourceGroupName $TargetVMRGName -TemplateUri $templateBlobFullURI -VirtualMachineName $NewVirtualMachineName
将在不等待上传结束的情况下被触发。
对于异步上传,https://api.jquery.com/ajaxcomplete/ 非常有用。
这段来自 Drupal 世界的代码完成了这项工作:
.change
});