Javascript 图像压缩程序脚本[注意:在中只能通过引用传递变量]
我试图把它关闭这个错误我不明白为什么会发生,因为我上传的文件正确。。。现在正在上载文件,它向我显示了错误通知:在 注意:在中只有变量应该通过引用传递 第10行的D:\xampp\htdocs\reduce image\upload.php ** 我面临的是upload.php代码。它显示了这个错误: **Javascript 图像压缩程序脚本[注意:在中只能通过引用传递变量],javascript,php,Javascript,Php,我试图把它关闭这个错误我不明白为什么会发生,因为我上传的文件正确。。。现在正在上载文件,它向我显示了错误通知:在 注意:在中只有变量应该通过引用传递 第10行的D:\xampp\htdocs\reduce image\upload.php ** 我面临的是upload.php代码。它显示了这个错误: ** ` **upload.php** <pre> <?php include('header.php'); ?> <script type="text
`
**upload.php**
<pre>
<?php
include('header.php');
?>
<script type="text/javascript" src="scripts/jquery.form.js"></script>
<script type="text/javascript" src="scripts/upload.js"></script>
<link type="text/css" rel="stylesheet" href="style.css" />
<link type="text/css" rel="stylesheet" href="style.css" />
<div class="container">
<h2>Reduce or Compress Image Size While Uploading in PHP</h2>
<form method="post" name="upload_form" id="upload_form" enctype="multipart/form-data" action="upload.php">
<label>Choose Images to Upload</label>
<input type="file" name="upload_images" id="image_file">
<div class="file_uploading hidden">
<label> </label>
<img src="uploading.gif" alt="Uploading......"/>
</div>
</form>
<div id="uploaded_images_preview">
</div>
</div>
<?php include('footer.php');?>
</pre>`
**js.file**
<pre>
$(document).ready(function(){
$('#image_file').on('change',function(){
$('#upload_form').ajaxForm({
target:'#uploaded_images_preview',
beforeSubmit:function(e){
$('.file_uploading').show();
},
success:function(e){
$('.file_uploading').hide();
},
error:function(e){
}
}).submit();
});
});
</pre> ```
```
在PHP中上载时减小或压缩图像大小
选择要上载的图像
`
**js.file**
$(文档).ready(函数(){
$('#image_file')。在('change',function()上{
$('#上传表单')。ajaxForm({
目标:“#上传的(图像)预览”,
提交前:功能(e){
$('.file_').show();
},
成功:职能(e){
$('.file_').hide();
},
错误:函数(e){
}
}).submit();
});
});
```
来自
此数组是通过引用传递的,因为它是由函数修改的这意味着您必须传递一个实变量,而不是返回数组的函数,因为只能通过引用传递实变量。
但是,您要向它传递一个返回数组的函数
试一试
<pre>
<?php
include('header.php');
?>
<script type="text/javascript" src="scripts/jquery.form.js"></script>
<script type="text/javascript" src="scripts/upload.js"></script>
<link type="text/css" rel="stylesheet" href="style.css" />
<link type="text/css" rel="stylesheet" href="style.css" />
<div class="container">
<h2>Reduce or Compress Image Size While Uploading in PHP</h2>
<form method="post" name="upload_form" id="upload_form" enctype="multipart/form-data" action="upload.php">
<label>Choose Images to Upload</label>
<input type="file" name="upload_images" id="image_file">
<div class="file_uploading hidden">
<label> </label>
<img src="uploading.gif" alt="Uploading......"/>
</div>
</form>
<div id="uploaded_images_preview">
</div>
</div>
<?php include('footer.php');?>
</pre>`
**js.file**
<pre>
$(document).ready(function(){
$('#image_file').on('change',function(){
$('#upload_form').ajaxForm({
target:'#uploaded_images_preview',
beforeSubmit:function(e){
$('.file_uploading').show();
},
success:function(e){
$('.file_uploading').hide();
},
error:function(e){
}
}).submit();
});
});
</pre> ```
$parts = explode(".", $file_name);
$extension = end($parts);