我想在没有文件管理器的情况下制作上传图片,我想要从pc上传目录
HTML code
<div id="tab-image">
<table id="images" class="list">
<thead>
<tr>
<td class="left"><?php echo $entry_title; ?></td>
<td class="left"><?php echo $entry_link; ?></td>
<td class="left"><?php echo $entry_image_banner; ?></td>
<td></td>
</tr>
</thead>
<?php $image_row = 0; ?>
<?php foreach ($shop_images as $shop_image) { ?>
<tbody id="image-row<?php echo $image_row; ?>">
<tr>
<td class="left"><?php foreach ($languages as $language) { ?>
<input type="text" name="shop_image[<?php echo $image_row; ?>][shop_image_description][<?php echo $language['language_id']; ?>][title]" value="<?php echo isset($shop_image['shop_image_description'][$language['language_id']]) ? $shop_image['shop_image_description'][$language['language_id']]['title'] : ''; ?>" />
<img src="catalog/view/theme/mall/image/flags/<?php echo $language['image']; ?>" title="<?php echo $language['name']; ?>" /><br />
<?php if (isset($error_shop_image[$image_row][$language['language_id']])) { ?>
<span class="error"><?php echo $error_shop_image[$image_row][$language['language_id']]; ?></span>
<?php } ?>
<?php } ?></td>
<td class="left"><input type="text" name="shop_image[<?php echo $image_row; ?>][link]" value="<?php echo $shop_image['link']; ?>" /></td>
<td class="left"><div class="image"><img src="<?php echo $shop_image['thumb']; ?>" alt="" id="thumb<?php echo $image_row; ?>" />
<input type="hidden" name="shop_image[<?php echo $image_row; ?>][image]" value="<?php echo $shop_image['image']; ?>" id="image<?php echo $image_row; ?>" />
<br />
<a onclick="image_upload(\'image' + image_row + '\', \'thumb' + image_row + '\');" id="simple-image"><?php echo $text_browse; ?></a> | <a onclick="$('#thumb<?php echo $image_row; ?>').attr('src', '<?php echo $no_image; ?>'); $('#image<?php echo $image_row; ?>').attr('value', '');"><?php echo $text_clear; ?></a></div></td>
<td class="left"><a onclick="$('#image-row<?php echo $image_row; ?>').remove();" class="button"><?php echo $button_remove; ?></a></td>
</tr>
</tbody>
<?php $image_row++; ?>
<?php } ?>
<tfoot>
<tr>
<td colspan="3"></td>
<td class="left"><a onclick="addImage();" class="button"><?php echo $button_add_image; ?></a></td>
</tr>
</tfoot>
</table>
</div>
&#13;
和图片行的javascript代码是: -
<script type="text/javascript"><!--
var image_row = <?php echo $image_row; ?>;
function addImage() {
html = '<tbody id="image-row' + image_row + '">';
html += ' <tr>';
html += ' <td class="left"><div class="image"><img src="<?php echo $no_image; ?>" alt="" id="thumb' + image_row + '" /><input type="hidden" name="product_image[' + image_row + '][image]" value="" id="image' + image_row + '" /><br /><a onclick="image_upload(\'image' + image_row + '\', \'thumb' + image_row + '\');" id="simple-image"><?php echo $text_browse; ?></a> | <a onclick="$(\'#thumb' + image_row + '\').attr(\'src\', \'<?php echo $no_image; ?>\'); $(\'#image' + image_row + '\').attr(\'value\', \'\');"><?php echo $text_clear; ?></a></div></td>';
html += ' <td class="right"><input type="text" name="product_image[' + image_row + '][sort_order]" value="" size="2" /></td>';
html += ' <td class="left"><a onclick="$(\'#image-row' + image_row + '\').remove();" class="button"><?php echo $button_remove; ?></a></td>';
html += ' </tr>';
html += '</tbody>';
$('#images tfoot').before(html);
image_row++;
}
//--></script>
&#13;
<script type="text/javascript"><!--
function image_upload(field, thumb) {
$('#dialog').remove();
$('#content').prepend('<div id="dialog" style="padding: 3px 0px 0px 0px;"><iframe src="index.php?route=common/filemanager&token=<?php echo $token; ?>&field=' + encodeURIComponent(field) + '" style="padding:0; margin: 0; display: block; width: 100%; height: 100%;" frameborder="no" scrolling="auto"></iframe></div>');
$('#dialog').dialog({
title: '<?php echo $text_image_manager; ?>',
close: function (event, ui) {
if ($('#' + field).attr('value')) {
$.ajax({
url: 'index.php?route=common/filemanager/image&token=<?php echo $token; ?>&image=' + encodeURIComponent($('#' + field).attr('value')),
dataType: 'text',
success: function(text) {
$('#' + thumb).replaceWith('<img src="' + text + '" alt="" id="' + thumb + '" />');
}
});
}
},
bgiframe: false,
width: 800,
height: 400,
resizable: false,
modal: false
});
};
//--></script>
&#13;
请帮助
我达到了这个javascript代码,这使我从pc浏览图像只是为第一行工作。 我想让它适用于我添加的每一行
<script type="text/javascript"><!--
function image_upload(field, thumb) {
var btnUpload=$('#simple-image');
new AjaxUpload(btnUpload, {
action: 'index.php?route=common/filemanager/upload&image=' + encodeURIComponent($('#' + field).attr('value')),
name: 'image',
autoSubmit: true,
responseType: 'json',
onChange: function(file, extension) {
this.setData({'directory': ''});
this.submit();
},
onSubmit: function(file, extension) {
$('#upload').append('<img src="catalog/view/theme/mall/image/loading.gif" class="loading" style="padding-left: 5px;" />');
},
onComplete: function(file, json) {
if (json.success) {
$('#' + field).attr('value','data/user/'+file);
$.ajax({
url: 'index.php?route=common/filemanager/image&image=' + encodeURIComponent($('#' + field).attr('value')),
dataType: 'text',
success: function(text) {
$('#' + thumb).replaceWith('<img src="' + text + '" alt="" id="' + thumb + '" />');
}
});
}
if (json.error) {
alert(json.error);
}
$('.loading').remove();
}
});
};
//--></script>
&#13;
答案 0 :(得分:0)
您可以使用FTP管理器上传文件。像Filezilla这样适用于Mac Windows和Linux的东西应该可以正常工作。只需FTP到您的服务器,您就可以直接从PC上传。