你能给我解释一下吗? [英] Can you explain me this?

查看:71
本文介绍了你能给我解释一下吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我有一些用于上传多张图片的代码,我是从网站上获得的.

就是这样:

Hello,

I''ve some code for uploading multiple images, I got it from a website.

Here''s it :

<?php

$upload_image_limit = 5; // How many images you want to upload at once?
$upload_dir			= "images_pending/"; // default script location, use relative or absolute path


################################# UPLOAD IMAGES
	
	foreach($_FILES as $k => $v){ 

	$img_type = "";

	### $htmo .= "$k => $v<hr />"; 	### print_r($_FILES);

	if( !$_FILES[$k]['error'] && preg_match("#^image/#i", $_FILES[$k]['type']) && $_FILES[$k]['size'] < 1000000){

	$img_type = ($_FILES[$k]['type'] == "image/jpeg") ? ".jpg" : $img_type ;
	$img_type = ($_FILES[$k]['type'] == "image/gif") ? ".gif" : $img_type ;
	$img_type = ($_FILES[$k]['type'] == "image/png") ? ".png" : $img_type ;

	$img_rname = $_FILES[$k]['name'];
	$img_path = $upload_dir.$img_rname;

	copy( $_FILES[$k]['tmp_name'], $img_path ); 
	$feedback .= "Image and thumbnail created $img_rname<br />";

			}
		}






############################### HTML FORM
	while($i++ < $upload_image_limit){
	$form_img .= '<label>Image '.$i.': </label> <input type="file" name="uplimg'.$i.'"><br />';
	}

	$htmo .= '
	<p>'.$feedback.'</p>
	<form method="post" enctype="multipart/form-data">
	'.$form_img.' <br />
	<input type="submit" value="Upload Images!" style="margin-left: 50px;" />
	</form>
	';	

	echo $htmo;



它很棒.但是有人可以向我简要介绍一下那里发生的事情吗?在那个foreach循环中?我对PHP知之甚少.没有进步.可以帮忙吗?

谢谢^ 2!



It works awesome. But could someone explain me briefly about what happens in there? in that foreach loop? I know PHP very little. Nothing advanced. Can help?

Thanks^2 !

推荐答案

upload_image_limit = 5 ; // 您一次要上传多少张图片?
upload_image_limit = 5; // How many images you want to upload at once?


upload_dir = " ; // 默认脚本位置,使用相对或绝对路径 ################################上传图像 foreach(
upload_dir = "images_pending/"; // default script location, use relative or absolute path ################################# UPLOAD IMAGES foreach(


_FILES as
_FILES as


这篇关于你能给我解释一下吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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