Php 图像上传集成到注册页面

Php 图像上传集成到注册页面,php,mysql,image,upload,Php,Mysql,Image,Upload,请给我建议:我想将图像上传集成到我的注册过程中。您是否知道用于此目的的插件或脚本(上载、调整大小、将链接放入db_表)?您可以在mysql中上载图像,并使用imagemagic或gd库调整其大小。您可以使用,但请注意,您的表单元素还必须具有属性enctype=“multipart/form data” 对于图像缩放,可以使用GD库中的函数。在“php规模图像”上快速搜索可以找到许多关于该主题的有用链接 更不用说还有很多有用的示例脚本,包括您正在寻找的示例脚本 看起来您对PHP还很陌生。我建议你去

请给我建议:我想将图像上传集成到我的注册过程中。您是否知道用于此目的的插件或脚本(上载、调整大小、将链接放入db_表)?

您可以在mysql中上载图像,并使用imagemagic或gd库调整其大小。

您可以使用,但请注意,您的表单元素还必须具有属性
enctype=“multipart/form data”

对于图像缩放,可以使用GD库中的函数。在“php规模图像”上快速搜索可以找到许多关于该主题的有用链接

更不用说还有很多有用的示例脚本,包括您正在寻找的示例脚本


看起来您对PHP还很陌生。我建议你去了解一下情况。将其用作第一个PHP资源,然后在internet上发表文章。在你用尽所有其他选择后,来这里。看起来你甚至没有试图解决这个问题,也没有亲自研究。

你可以看一个文件上传器,比如:和phpthumb来调整大小,尽管正如其他海报所提到的,如果你想了解更多,自己做并不复杂。

找到下面的php代码,使用GD库上传和裁剪图像

<?php
function createThumb($upfile, $dstfile, $max_width, $max_height){
   $size = getimagesize($upfile);
   $width = $size[0];
   $height = $size[1];
   $x_ratio = $max_width / $width;
   $y_ratio = $max_height / $height;
   if( ($width <= $max_width) && ($height <= $max_height)) {
           $tn_width = $width;
           $tn_height = $height;
   } elseif (($x_ratio * $height) < $max_height) {
           $tn_height = ceil($x_ratio * $height);
           $tn_width = $max_width;
   } else {
           $tn_width = ceil($y_ratio * $width);
           $tn_height = $max_height;
   }
   if($size['mime'] == "image/jpeg"){
           $src = ImageCreateFromJpeg($upfile);
           $dst = ImageCreateTrueColor($tn_width, $tn_height);
           imagecopyresampled($dst, $src, 0, 0, 0, 0, $tn_width, $tn_height,$width, $height);
           imageinterlace( $dst, true);
           ImageJpeg($dst, $dstfile, 100);
   } else if ($size['mime'] == "image/png"){
           $src = ImageCreateFrompng($upfile);
           $dst = ImageCreateTrueColor($tn_width, $tn_height);
           imagecopyresampled($dst, $src, 0, 0, 0, 0, $tn_width, $tn_height,$width, $height);
           Imagepng($dst, $dstfile);

   } else {

           $src = ImageCreateFromGif($upfile);
           $dst = ImageCreateTrueColor($tn_width, $tn_height);
           imagecopyresampled($dst, $src, 0, 0, 0, 0, $tn_width, $tn_height,$width, $height);
           imagegif($dst, $dstfile);
   }
}

//usage

if(isset($_FILES['upload_Image']['name']) && $_FILES['upload_Image']['name']!=='') {
    $ext = substr($_FILES['upload_Image']['name'], strpos($_FILES['upload_Image']['name'],'.'), strlen($_FILES['upload_Image']['name'])-1); 

    $imgNormal = time().$ext;
    $normalDestination = "Photos/Orignal/" . $imgNormal;
    $httpRootLarge = "Photos/Large/" . $imgNormal;
    $httpRootSmall = "Photos/Small/" . $imgNormal;
    $httpRootThumb = "Photos/Thumb/" . $imgNormal;
    move_uploaded_file($_FILES['upload_Image']['tmp_name'], $normalDestination);
    createThumb($normalDestination,$httpRootLarge,680,604); #For 604x604 Image 
    createThumb($normalDestination,$httpRootSmall,500,300); #For 500x300 Image
    createThumb($normalDestination,$httpRootThumb,130,100); #For 130x100 Image
}
?>
<form action="" method="post" enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="upload_Image" id="upload_Image" />
<br />
<input type="submit" name="submit" value="Submit" />
</form>

文件名:


在mysql表中保存$imgNormal值。

到mysql表中吗?不。我想把它们上传到文件夹中,然后获取图像的链接并将该链接放到dn表中。您有用于此目的的php脚本吗?如果您想上传到文件夹中。您必须为文件夹设置正确的权限,并使用enctype=“multipart/form data”使用表单上载,并使用$\u文件进行访问。在提出此问题之前,您做了哪些研究?我没有发现任何可以上载和调整大小的内容。如果你知道一些脚本,请给我一个链接