我想在视图中上传图片并将数据保存在数据库使用表单中,但是当按下提交按钮时,我得到一些错误当我有调用成员函数hasFile()时在我的计算机上选择的图像,如何修复该错误,以便我可以上传图像和保存数据库上的数据。谢谢你的回答。
此处控制器中的代码:
import javafx.application.Platform;
import javafx.concurrent.Service;
import javafx.concurrent.Task;
import javafx.scene.control.Label;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import tools.InfoTool;
public class MoveTitleService extends Service<Void>{
private String title;
volatile boolean doAnimation;
private int counter;
public Label movingText = new Label("A reallyyy big teeeeexxxxxxxxxxxxxxxxxxxxxxxt");
/**
*Constructor
*/
public MoveTitleService() {
movingText.setFont(Font.font("null",FontWeight.BOLD,14));
movingText.setTextFill(Color.WHITE);
setOnSucceeded( s ->{
movingText.setText("");
});
}
//Start the Service
public void startTheService(String title) {
this.title = title;
doAnimation = true;
restart();
}
//Stop the Service
public void stopService(){
doAnimation=false;
}
@Override
protected Task<Void> createTask() {
return new Task<Void>() {
@Override
protected Void call() throws Exception {
while (doAnimation) {
//System.out.println("MoveTitleService is Running...");
// One letter at a time
for (int m = 0; m <= title.length(); m++) {
counter=m;
Platform.runLater( () ->{
movingText.setText(title.substring(0, counter) + addSpaces(title.length() - counter));
});
if(!doAnimation) break;
Thread.sleep(150);
}
// Disappearing to back
for (int m = 0; m < title.length(); m++) {
counter=m;
Platform.runLater( () ->{
movingText.setText(title.substring(counter));
});
if(!doAnimation) break;
Thread.sleep(150);
}
// Appearing to front
for (int m = 1; m <= title.length(); m++) {
counter=m;
Platform.runLater( () ->{
movingText.setText(title.substring(title.length() - counter));
});
if(!doAnimation) break;
Thread.sleep(150);
}
if(!doAnimation) break;
for(int i=0; i<3000/150; i++)
Thread.sleep(150);
Thread.sleep(3000);
}
return null;
}
private String addSpaces(int spaces) {
String z = "";
for (int i = 0; i <= spaces; i++)
z += " ";
return z;
}
};
}
}
这里有一些脚本表格文件:
public function UploadFile()
{
$file = Input::file('image');
if($file->hasFile('image'))
{
$name = $datas->kode_barang.'.jpg';
$file->move(public_path().'/assets/images/barang/', $name);
$newpath = public_path().'/assets/images/barang/'.$name;
$dataGambar = new GambarModel;
$dataGambar -> kode_gambar = $datas->kode_barang;
$dataGambar -> nama_gambar = $file->getClientOriginalName();
$dataGambar -> path = $newpath;
$dataGambar -> kategori = 'barang';
$dataGambar->save();
Session::flash('message', 'Berhasil menambahkan barang !');
return Redirect::to('/barang');
}
else
{
Session::flash('message', 'Upload tidak berhasil'.$file->getPathName() );
return Redirect::to('/barang');
}
}
答案 0 :(得分:0)
在表单标记中添加char str[] = "foobar";
size_t str_len = strlen(str);
char rev[str_len + 1];
rev[str_len] = '\0';
for (int i = 0; i < str_len; i++)
rev[i] = str[str_len - i - 1];
printf("%s\n", rev);
。