简体   繁体   English

在内容处置中上传文件

[英]Upload file in Content Disposition

what's up 这是怎么回事

I'm trying to upload a file in Content Disposition. 我正在尝试在内容处置中上传文件。

I have a website who link 2 images with PHP. 我有一个网站,该网站用PHP链接了2张图片。 So, I have an image on my server and then I upload another image (Transparent with some objects for example), then I have a new image created with this code: 因此,我在服务器上有一个图像,然后上传另一个图像(例如,对某些对象透明),然后使用此代码创建了一个新图像:

imagecopymerge($src, $dest, 0, 0, 0, 0, 600, 600, 45);
header('Content-Disposition: Attachment; filename="flagperfil.png"');
header('Content-Type: image/png');
imagepng($src);
imagedestroy($dest);
imagedestroy($src);

It works, is PHP. 它有效,是PHP。 But now, this image doesn't have a direct link, is only a php file who have this new image. 但是现在,此图像没有直接链接,只有具有此新图像的php文件。

How can I upload this new image to my website? 如何将该新图像上传到我的网站?

Regards 问候

If you want to save the image, pass the second parameter as the file path/name where to save. 如果要保存图像,请将第二个参数作为保存位置的文件路径/名称。 Below code will save the image to where your script executed. 下面的代码会将图像保存到脚本执行的位置。 For example, if your script runing on www.example.com/image/script.php with below code your image will be saved to www.example.com/image/file.png 例如,如果您的脚本使用以下代码在www.example.com/image/script.php上运行,则您的图像将保存到www.example.com/image/file.png

    imagepng($src, "file.png"); 

If you want to save your image to other directory, give it to full path and name: 如果要将图像保存到其他目录,请为其提供完整路径和名称:

   imagepng($src, "/var/www/html/images/file.png"); 

See this: http://php.net/manual/en/function.imagepng.php#102944 看到这个: http : //php.net/manual/en/function.imagepng.php#102944

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM