小编Vip*_*ehl的帖子

如何使用php在mysql数据库中存储图像

如何在MySQL数据库中存储和显示图像.直到现在我只编写了代码来从用户那里获取图像并将它们存储在一个文件夹中,我现在写的代码是: HTML FILE

<input type="file" name="imageUpload" id="imageUpload">
Run Code Online (Sandbox Code Playgroud)

PHP文件

    $target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["imageUpload"]["name"]);
$uploadOk = 1;
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);


if (move_uploaded_file($_FILES["imageUpload"]["tmp_name"], $target_file)) {
    echo "The file ". basename( $_FILES["imageUpload"]["name"]). " has been uploaded.";
} else {
    echo "Sorry, there was an error uploading your file.";}
Run Code Online (Sandbox Code Playgroud)

html php mysql image-uploading

7
推荐指数
1
解决办法
11万
查看次数

在HashSet中搜索时如何使用正则表达式

我正在编写一个 Java 程序,我需要在其中搜索 Set 中的特定单词。必须搜索的词类似于 ("wo.d") where '.' 可以用任何其他字母代替。我正在使用正则表达式来匹配这种类型的单词案例。

这是我到目前为止

HashSet<String> words = new HashSet<String>();//this set is already populated
String word = "t.st";
if(word.contains(".")){
    Pattern p = Pattern.compile(word);
    Matcher m;
    boolean match = false;
    for(String setWord : words){
        m = p.matcher(setWord);
        if(m.matches())
            match = true;
    }
    if(match)
        System.out.println("Its a match");
    else
        System.out.println("Its not a match");
}
else{
    System.out.println("The word does not contain regex do other stuff");
}
Run Code Online (Sandbox Code Playgroud)

上面的代码有效但效率不高,因为它在一秒钟内被调用多次。所以它会在程序中产生滞后。

java regex set

2
推荐指数
1
解决办法
3207
查看次数

标签 统计

html ×1

image-uploading ×1

java ×1

mysql ×1

php ×1

regex ×1

set ×1