Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 我想从文件夹中获取图像并将图像上载到另一个文件夹,而不使用任何输入类型文件?_Php_Mysql - Fatal编程技术网

Php 我想从文件夹中获取图像并将图像上载到另一个文件夹,而不使用任何输入类型文件?

Php 我想从文件夹中获取图像并将图像上载到另一个文件夹,而不使用任何输入类型文件?,php,mysql,Php,Mysql,我想从文件夹中获取图像并将图像上载到另一个文件夹,而不使用任何输入类型文件?但我现在正在从管理员/上传中获取图像 这里是我的页面代码 <?php $size = 200; // the thumbnail height $filedir = 'uploads/'; // the directory for the original image $thumbdir = 'uploads/'; // the directory for the thumbnail image

我想从文件夹中获取图像并将图像上载到另一个文件夹,而不使用任何输入类型文件?但我现在正在从管理员/上传中获取图像

这里是我的页面代码

<?php
$size = 200; // the thumbnail height
     $filedir = 'uploads/'; // the directory for the original image
     $thumbdir = 'uploads/'; // the directory for the thumbnail image
     $prefix = 'small0_'; // the prefix to be added to the original name
     $maxfile = '2000000';
     $mode = '0666';
     $rnd_1 = rand(11111,99999); 

     $userfile_name= $rnd_1.'_'.$_FILES['image']["name"];
     $userfile_tmp = $_FILES['image']['tmp_name'];
     $userfile_size = $_FILES['image']['size'];
     $userfile_type = $_FILES['image']['type'];
     if (isset($_FILES['image']['name'])) 
     {
         $prod_img = $filedir.$userfile_name;
         $prod_img_thumb = $thumbdir.$prefix.$userfile_name;
         move_uploaded_file($userfile_tmp, $prod_img);
         chmod ($prod_img, octdec($mode));
         $sizes = getimagesize($prod_img);
        $aspect_ratio = $sizes[1]/$sizes[0]; 
         if ($sizes[1] <= $size)
         {

             $new_width = '500';
             $new_height = '500';
         }else{

             $new_width = '500';
             $new_height = '500';
         }
             $destimg=ImageCreateTrueColor($new_width,$new_height)
             or die('Problem In Creating image');

           $srcimg=ImageCreateFromJPEG($prod_img)
         or $srcimg=ImageCreateFromPNG($prod_img)
         or $srcimg=ImageCreateFromGIF($prod_img)
             or die('Problem In opening Source Image0');
         if(function_exists('imagecopyresampled'))
         {
             imagecopyresampled($destimg,$srcimg,0,0,0,0,$new_width,$new_height,ImageSX($srcimg),ImageSY($srcimg))
             or die('Problem In resizing');
         }else{
             Imagecopyresized($destimg,$srcimg,0,0,0,0,$new_width,$new_height,ImageSX($srcimg),ImageSY($srcimg))
             or die('Problem In resizing');
         }
         ImageJPEG($destimg,$prod_img_thumb,90)
             or die('Problem In saving');
     }
?>

 <img name="image" id="image" src="admin/uploads/small0_<?php echo $image?>"   width="150" height="150">

“width=“150”height=“150”>

我从管理员处获取图像/上传现在我想将购物车产品图像电影到另一个文件夹中,而不使用输入类型文件

如果它已经在服务器上,就应该这样做。

我看到你正在调用
移动上传的文件
它不是将其移动到正确的文件夹中吗?此脚本正在使用管理面板,但使用了i输入类型文件,但我想这个脚本将在购物车页面没有输入类型的工作file@FarhanDharsi我不知道你在问什么。我想在没有输入类型文件的情况下移动购物产品图像。请尝试我发布的
重命名
方法。
<?php
$size = 200; // the thumbnail height
     $filedir = 'uploads/'; // the directory for the original image
     $thumbdir = 'uploads/'; // the directory for the thumbnail image
     $prefix = 'small0_'; // the prefix to be added to the original name
     $maxfile = '2000000';
     $mode = '0666';
     $rnd_1 = rand(11111,99999); 

     $userfile_name= $rnd_1.'_'.$_FILES['image']["name"];
     $userfile_tmp = $_FILES['image']['tmp_name'];
     $userfile_size = $_FILES['image']['size'];
     $userfile_type = $_FILES['image']['type'];
     if (isset($_FILES['image']['name'])) 
     {
         $prod_img = $filedir.$userfile_name;
         $prod_img_thumb = $thumbdir.$prefix.$userfile_name;
         move_uploaded_file($userfile_tmp, $prod_img);
         chmod ($prod_img, octdec($mode));
         $sizes = getimagesize($prod_img);
        $aspect_ratio = $sizes[1]/$sizes[0]; 
         if ($sizes[1] <= $size)
         {

             $new_width = '500';
             $new_height = '500';
         }else{

             $new_width = '500';
             $new_height = '500';
         }
             $destimg=ImageCreateTrueColor($new_width,$new_height)
             or die('Problem In Creating image');

           $srcimg=ImageCreateFromJPEG($prod_img)
         or $srcimg=ImageCreateFromPNG($prod_img)
         or $srcimg=ImageCreateFromGIF($prod_img)
             or die('Problem In opening Source Image0');
         if(function_exists('imagecopyresampled'))
         {
             imagecopyresampled($destimg,$srcimg,0,0,0,0,$new_width,$new_height,ImageSX($srcimg),ImageSY($srcimg))
             or die('Problem In resizing');
         }else{
             Imagecopyresized($destimg,$srcimg,0,0,0,0,$new_width,$new_height,ImageSX($srcimg),ImageSY($srcimg))
             or die('Problem In resizing');
         }
         ImageJPEG($destimg,$prod_img_thumb,90)
             or die('Problem In saving');
     }
?>

 <img name="image" id="image" src="admin/uploads/small0_<?php echo $image?>"   width="150" height="150">