上传的文件第一个字母被切断
我正在将网站从具有 WS2003、IIS6、PHP 5.2 的服务器迁移到具有 WS2008、IIS7 和 PHP 5.3 的服务器
我有一个 html 表单,可将文件上传到该网站。
<?php
if(isset($_POST["Upload"])){
echo "<pre>";
print_r($_POST);
print_r($_FILES);
echo "</pre>";
}
?>
<form action="tester.php" method="post" enctype="multipart/form-data">
<input type="hidden" name="Upload" value="1" />
<input type="hidden" name="MAX_FILE_SIZE" value="4500000" />
<input type="file" name="artImage" id="artImage" />
<input type="submit" />
</form>
在旧服务器上工作得很好,但在新服务器上,它无缘无故地砍掉了第一个字母,我看不出原因。我不知道这是 IIS 设置还是 PHP 设置。
输出:
Array
(
[Upload] => 1
[MAX_FILE_SIZE] => 4500000
)
Array
(
[artImage] => Array
(
[name] => easons_Change_(HD_Ready).jpg
[type] => image/pjpeg
[tmp_name] => C:\Windows\Temp\php99.tmp
[error] => 0
[size] => 498879
)
)
旧服务器的输出,相同的代码,相同的文件:
Array
(
[Upload] => 1
[MAX_FILE_SIZE] => 4500000
)
Array
(
[artImage] => Array
(
[name] => Seasons_Change_(HD_Ready).jpg
[type] => image/pjpeg
[tmp_name] => C:\WINDOWS\Temp\php6835.tmp
[error] => 0
[size] => 498879
)
)
I'm migrating a website from a server with WS2003, IIS6, PHP 5.2 over to a server with WS2008, IIS7 and PHP 5.3
I have a html form that uploads files to the site.
<?php
if(isset($_POST["Upload"])){
echo "<pre>";
print_r($_POST);
print_r($_FILES);
echo "</pre>";
}
?>
<form action="tester.php" method="post" enctype="multipart/form-data">
<input type="hidden" name="Upload" value="1" />
<input type="hidden" name="MAX_FILE_SIZE" value="4500000" />
<input type="file" name="artImage" id="artImage" />
<input type="submit" />
</form>
Works great on the old server, but on the new server, it chops off the first letter for no reason I can see. I don't know if it's an IIS setting, or a PHP setting.
Output:
Array
(
[Upload] => 1
[MAX_FILE_SIZE] => 4500000
)
Array
(
[artImage] => Array
(
[name] => easons_Change_(HD_Ready).jpg
[type] => image/pjpeg
[tmp_name] => C:\Windows\Temp\php99.tmp
[error] => 0
[size] => 498879
)
)
Output from the old server, same code, same file:
Array
(
[Upload] => 1
[MAX_FILE_SIZE] => 4500000
)
Array
(
[artImage] => Array
(
[name] => Seasons_Change_(HD_Ready).jpg
[type] => image/pjpeg
[tmp_name] => C:\WINDOWS\Temp\php6835.tmp
[error] => 0
[size] => 498879
)
)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这看起来像是您遇到的错误 $_FILES 'name' 上传后缺少第一个字符。
我也有同样的问题。
This looks like the bug you are experiencing $_FILES 'name' missing first character after upload.
I am having the same issue.
我遇到了同样的问题并进行了很多搜索,但这是一个错误,我不知道为什么!但我有解决方案并且它也有效。
只需在文件名前加上名称即可。例子 :
I had same issue and search a lot but it's a bug and I don't know why! But I have solution and it works as well.
Just prefix a name before file name. Example :