Php 从技术上讲,是否可以将OpenCart上载文件夹更改为其他服务器?
从技术上讲,在OpenCart 2.0中可以更改上载文件夹,客户可以在其中上载文件?基本上,它是在config.php中(在root和admin文件夹中)定义的,如下所示:Php 从技术上讲,是否可以将OpenCart上载文件夹更改为其他服务器?,php,file-upload,upload,opencart,opencart2.x,Php,File Upload,Upload,Opencart,Opencart2.x,从技术上讲,在OpenCart 2.0中可以更改上载文件夹,客户可以在其中上载文件?基本上,它是在config.php中(在root和admin文件夹中)定义的,如下所示: define('DIR_UPLOAD', '/home/www/shop/system/upload/'); 是否可以简单地更改该目的地(例如到另一台服务器) 目前我正在使用此代码(只需修改catalog/../product/product.tpl): &时代; 接近 成功验证码后,在iframe中运行index.p
define('DIR_UPLOAD', '/home/www/shop/system/upload/');
是否可以简单地更改该目的地(例如到另一台服务器)
目前我正在使用此代码(只需修改catalog/../product/product.tpl):
&时代;
接近
成功验证码后,在iframe中运行index.php(在另一台服务器上运行,这是一个具有固定IP的网络连接存储):
要上载的文件:
这很好,您可以轻松地将文件上载到服务器,但我正在寻找更好的解决方案。这并没有像opencart通常那样连接订单和上传的文件 是的,它会起作用,但你必须记住一些事情
它会很好用。是的,它会很好用,但你必须记住一些事情
它可以正常工作。使用CURL库也可以。请查看以下链接。这可能与CURL库有关。请参阅以下链接。“(例如到另一台服务器)”——这不是“例如”的事情,而是完全改变了问题的范围。通常,文件上传仅在脚本运行的服务器的文件系统中进行处理,并且通过简单修改该常数的值,将文件从该服务器传输到其他服务器很可能不起作用,但更可能需要对实际处理上传文件的代码进行更深刻的修改。”(例如到另一台服务器)”——这不是“例如”的事情,而是完全改变了问题的范围。通常,文件上传仅在脚本运行的服务器的文件系统中进行处理,并且通过简单修改该常数的值,将文件从该服务器传输到其他服务器很可能不起作用,但更可能需要对实际处理上传文件的代码进行更深入的修改。
<?php if ($option['type'] == 'file') { ?>
<!-- Button trigger modal -->
<button type="button" class="btn btn-default btn-block" data-toggle="modal" data-target="#myModal">
<i class="fa fa-upload"></i> <?php echo $button_upload; ?>
</button>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel"><?php echo $button_upload; ?></h4>
</div>
<div class="modal-body embed-responsive">
<iframe height="300px" width="350px" frameborder="0" class="embed-responsive-item" src="captcha/captcha.php"></iframe>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<!DOCTYPE html>
<html>
<body>
<form action="index.php?new_upload=true" method="post" enctype="multipart/form-data">
File to upload:
<input type="file" name="fileToUpload" id="fileToUpload"><input type="submit" value="Upload" name="submit">
</form>
<?php
if (isset($_GET['new_upload'])) {
upload();
}
function upload() {
$target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$fileType = pathinfo($target_file,PATHINFO_EXTENSION);
// Check if file already exists
if (file_exists($target_file)) {
echo "Sorry, file already exists.";
$uploadOk = 0; break;
}
// Check file size
if ($_FILES["fileToUpload"]["size"] > 10000000) {
echo "Sorry, your file is too large.";
$uploadOk = 0; break;
}
// Allow certain file formats
if($fileType != "jpg" && $fileType != "png" && $fileType != "jpeg" && $fileType != "pdf" && $fileType != "JPG" && $fileType != "JPEG" && $fileType != "gif" ) {
echo "Sorry, only JPG, JPEG, PNG, PDF & GIF files are allowed.";
$uploadOk = 0; break;
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
echo "Sorry, your file was not uploaded."; break;
// if everything is ok, try to upload file
} else {
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
chmod($target_file, 0777); //change permission
} else {
echo "Sorry, there was an error uploading your file.";
}
}
}
?>
</body>
</html>