如何暂停循环以允许用户选择变量

时间:2016-04-28 02:54:09

标签: bash

我似乎无法弄清楚如何为用户选择进行此循环暂停。它每次都会自动选择<?php $name= 'filename'; $newname= '/images/'. $name;//. '.jpg'; // why wouldn't you preserve the correct extension? i.e. $file_ext if(isset($_FILES['image'])){ $errors= array(); $file_name = $_FILES['image']['name']; $file_size =$_FILES['image']['size']; $file_tmp =$_FILES['image']['tmp_name']; $file_type=$_FILES['image']['type']; $file_ext=strtolower(end(explode('.',$_FILES['image']['name']))); $expensions= array("jpeg","jpg","png"); if(in_array($file_ext,$expensions)=== false){ $errors[]="extension not allowed, please choose a JPEG or PNG file."; } /*if($file_size > 2097152){ $errors[]='File size must be excately 2 MB'; }*/ if(empty($errors)==true){ // // // use move_uploaded_file() instead // // // //rename($file_tmp, $newname); move_uploaded_file($file_tmp, "$newname.$file_ext"); echo "Success"; }else{ print_r($errors); } } ?> <form action="" method="POST" enctype="multipart/form-data"> <input type="file" name="image" /> <input type="submit"/> </form> 选项。我做错了什么?

*

1 个答案:

答案 0 :(得分:2)

您需要重定向“read abcde”以从tty读取。

read abcde < /dev/tty

由于while循环,stdin实际上来自重定向。