如何通过常量uploadpath上传多个imges

时间:2015-08-09 19:47:47

标签: php mysql mysqli

我使用下面的代码上传多张图片,但是当我通过不同的表单字段上传多张图片时显示错误。我的代码是:

$image = 'image'.$i.$j;
      $image_store = $_FILES[$image]['name'];
define('uploadpath','../images/');
      $target = uploadpath. $image_store ;

,错误是

CONSTANT uploadpath Already defined

1 个答案:

答案 0 :(得分:0)

与错误相同,您多次定义uploadpath,因为这一行:

define('uploadpath','../images/');

它必须在某个地方循环。从那里删除它(你只需要定义一次,所以把它放出循环),或者检查一下:

if(!defined('uploadpath')) define('uploadpath','../images/');