move_uploaded_file不起作用(已检查其他帖子) [英] move_uploaded_file not working (checked other posts)

查看:132
本文介绍了move_uploaded_file不起作用(已检查其他帖子)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我检查了至少10个答案,并尝试使用 DIR (常量,基名等)... 相同的脚本在其他文件中的工作方式像超级按钮一样,但是在此文件中却没有.

I checked at least 10 answers, tried with DIR with constant, with basename etc... Same script is working like a charm in other file, but not in this one...

$target = __DIR__ . "/img/blog/" . $_FILES['slika']['name'];
            //proveri da li postoji file za upload
            if (move_uploaded_file($_FILES['slika']['tmp_name'], $target)) {
                if (isset($_POST['published'])) {
                    $blog->_db->insert('ets_blog', array(
                        'kategorija' => $_POST['kategorija'],
                        'naslov' => $_POST['naslov'],
                        'tekst' => $_POST['text'],
                        'image' => $_FILES['slika']['name'],
                        'published' => 1
                    ));

无论如何,当我在移动(move_uploaded_file)之前移动此IF时,所有内容都像超级按钮一样工作,除了它不会创建文件,而是将他的名字存储在数据库中... 当我回显目标文件夹时,完全可以. 有什么建议吗?

Anyway, when i move this IF before (move_uploaded_file) everything is working like a charm except it doesnt create a file, but it stores his name in database... when i echo target folder it's totaly okay. Any suggestions?

推荐答案

尝试将您的$_FILES['slika']['name'];替换为此basename( $_FILES['slika']['name'] );.因为您的文件名未格式化

Try to replace your $_FILES['slika']['name']; with this basename( $_FILES['slika']['name'] ); . Beacuse your file name isn't formatted

这篇关于move_uploaded_file不起作用(已检查其他帖子)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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