使用php上传图片

时间:2018-08-31 19:25:30

标签: php html

我有一个输入类型的文件,该文件已隐藏并使用另一个按钮触发。.输入必须仅将图像上载到名为Covers的文件夹,但代码不起作用并且不上载任何图像。.
html代码

btn_request_sms.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            phone = inputPhone.getText().toString().trim();
            if (phone.length() == 13)
            {
                if (phone.startsWith("0")) {

                // here how to split string

                } else {
                    Toast.makeText(getApplicationContext(), "Mobile number is wrong", Toast.LENGTH_SHORT).show();
                }
            } else {
                Toast.makeText(getApplicationContext(), "Mobile length is wrong", Toast.LENGTH_SHORT).show();
            }
        }
    });


php代码:

library("tidyr")
library("dplyr")

 studyMissing <- studyAll %>%
   expand(YEAR, LINE, PLOT) %>%
   anti_join(studyAll, by = c("YEAR", "LINE", "PLOT"))

# Giving
# A tibble: 23 x 3 
#    YEAR LINE  PLOT 
#   <int> <fct> <fct>
# 1  1985 N     f    
# 2  1986 N     h    
# 3  1986 S     g    
# 4  1992 N     h    
# 5  1996 S     g    
# 6  2001 N     e    
# 7  2001 N     i    
# 8  2002 N     c    
# 9  2002 S     g    
#10  2003 N     h    
## ... with 13 more rows

我知道

  

致命错误:第7行D:\ XAMPP \ htdocs \ Warina \ connect.php中的未定义类常量'MYSQL_ATTR_INIT_COMMAND'

此后,我搜索了一个解决方案并得到了以下信息:<div class="cover"> <img src="Layout/images/cover.jpg" alt="cover" name="cover-img" class="cover-img"> <form action="<?php echo $_SERVER['PHP_SELF']?>" method="POST" enctype="multipart/form-data"> <button type="submit" name="submit-cover" id="cover-btn">Change Cover</button> <input type="file" name="avatar" id="cover-img-input" class="hidden" /> </form> 应该在我的php.ini中不加注释,并且现在也没有注释,我对此错误也感到困惑。

1 个答案:

答案 0 :(得分:0)

此行发送通知:

$avatarExtension = strtolower(end(explode('.',$avatarName)));
  

注意:只有变量应通过引用在xx行的file.php中传递

替换为

$avatarExtension = explode('.',$avatarName);
$avatarExtension = strtolower(end($avatarExtension));

修复此路径:

move_uploaded_file($avatarTempName, "Uploads\Covers\\" . $avatar);

使用

move_uploaded_file($avatarTempName, "Uploads\\Covers\\" . $avatar);

并确保它存在