php - 如何在 php mysql 博客中插入图像并在确切位置显示它们

标签 php mysql image blogs

我正在创建一个网站,管理员需要在其中发布他的作品。我需要为他制作一个控制面板,以便用新内容更新网站。内容将以研究论文的形式出现,即有点像博客文章。我已经成功启用了一个界面,他可以在其中输入标题、正文和标签或关键字。

我如何创建一些东西,让他可以上传多个图像以使他的作品更具吸引力 - 即允许他在他希望显示图像的确切位置插入图像。

我查了很多资料都没有找到合适的答案

最佳答案

使用 uploadify 并将其多个参数设置为 true

    <input type="file" name="file_upload" id="file_upload" />


        $(function() {
            $("#file_upload").uploadify({
                'multi'    : true,
                'swf'      : '/uploadify/uploadify.swf',
                'uploader' : '/uploadify/uploadify.php' ,
'onUploadSuccess' : function(file, data, response) {
        // Use the 'file' object to get the filename and stuff and put it somewhere on the page.
    }
            });
        });

服务器端:

$targetFolder = '/uploads'; // Relative to the root

if (!empty($_FILES)) {
    $tempFile = $_FILES['Filedata']['tmp_name'];
    $targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder;
    $targetFile = rtrim($targetPath,'/') . '/' . $_FILES['Filedata']['name'];

    // Validate the file type
    $fileTypes = array('jpg','jpeg','gif','png'); // File extensions
    $fileParts = pathinfo($_FILES['Filedata']['name']);

    if (in_array($fileParts['extension'],$fileTypes)) {
        move_uploaded_file($tempFile,$targetFile);
        echo $targetFolder . '/' . $_FILES['Filedata']['name'];
    } else {
        echo 'Invalid file type.';
    }
} 

关于php - 如何在 php mysql 博客中插入图像并在确切位置显示它们,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18452573/

相关文章:

php - 为什么我不能更改根目录?

php - 从 PHP(64 位操作系统)调用 nbtstat 命令

Apache Mahout 中的 MySQLJDBCDataModel

php - 尝试用 PHP 显示来自 MySQL 数据库的图像

java - Spring MVC - 从JSP表中删除记录

mysql - 如何忽略where子句中的条件

image-processing - 如何从相机拍摄的图像中计算物体的总像素数?

html - 根据 CSS 类在另一个图像之上添加图像

c# - 打印图像 c#.net

PHPMailer 内容传输编码