在php中上传文件时出错 [英] Error in file uploading in php

查看:60
本文介绍了在php中上传文件时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的HTML代码

 < form method =postenctype =multipart / form-dataaction = upload.php的> 
< input type =filename ='image'>
< input type =SUBMITvalue =提交>
< / form>

PHP代码(仅提及有错误的行)

 <?php 
list($ waste,$ extension)= explode(/,$ _ FILES [image] [type] ); echo $ extension;
?>

如果文件是图片,它会给文件扩展名,但在视频的情况下会给出错误。 / p>

错误

  :未定义的索引:第3行的D:\wamp\www\upload.php中的图像
调用堆栈
#时间内存函数位置
1 0.0007 364904 {main}()。 。\upload.php:0

(!)注意:未定义的偏移量:1在D:\ wamp\www\upload.php在第3行
调用堆栈
#时间记忆函数位置
1 0.0007 364904 {main}()..\upload.php:0

请告诉我如何使它可以用于视频上传。

解决方案

ini_set函数

  ini_set(max_filesize,150M); 


My HTML code

<form method="post" enctype="multipart/form-data" action="upload.php">
<input type="file" name='image' >
<input type="SUBMIT" value="Submit">
</form>

PHP code(Only the line which is errorneous is mentioned)

    <?php
    list($waste,$extension) = explode("/",$_FILES["image"]["type"]);echo $extension;
    ?>

It is giving file extension if the file is an image but it's giving error in case of video.

ERROR

( ! ) Notice: Undefined index: image in D:\wamp\www\upload.php on line 3
Call Stack
#   Time    Memory  Function    Location
1   0.0007  364904  {main}( )   ..\upload.php:0

( ! ) Notice: Undefined offset: 1 in D:\wamp\www\upload.php on line 3
Call Stack
#   Time    Memory  Function    Location
1   0.0007  364904  {main}( )   ..\upload.php:0

Please tell me how to make it work for video uploading also.

解决方案

The ini_set function is

ini_set("max_filesize","150M");

这篇关于在php中上传文件时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆