【发布时间】:2016-10-13 23:02:22
【问题描述】:
我开发了一个社交 android 应用程序,用户将 high quality image 上传到我的服务器,然后下载它们以显示在应用程序提要的列表视图中。
上传的图片保存在./uploads/ directory in my server.我使用PHP中的以下代码将图片保存在服务器中:
<?php
// Path to move uploaded files
error_reporting(E_ALL ^ E_DEPRECATED);
include 'conf.php';
$target_path = "uploads/";
// array for final json respone
$response = array();
// getting server ip address
$server_ip = gethostbyname(gethostname());
// final file url that is being uploaded
$file_upload_url = 'http://' . $server_ip . '/' . 'AndroidFileUpload' . '/' . $target_path;
if (isset($_FILES['image']['name'])) {
$target_path = $target_path . basename($_FILES['image']['name']);
try {
// Throws exception incase file is not being moved
if (!move_uploaded_file($_FILES['image']['tmp_name'], $target_path)) {
// make error flag true
print "error1";
}
print basename($_FILES['image']['name']);
} catch (Exception $e) {
// Exception occurred. Make error flag true
print "error2";
}
} else {
// File parameter is missing
print "error3";
}
?>
现在我想将每个image 的low resolution 保存在不同的目录中(或实时获取低分辨率)并获取它的url 并使用php 发送到android 应用程序,我的应用程序中的用户可以在下载整个 image 之前,请查看图像的 thumbnail 或低 resolution。
我应该怎么做?
【问题讨论】:
-
你可以下载timthumb.php并上传到服务器,你可以使用timthumb.php后的图片路径?scr=image.jpg&h=height&w=width&zc=cropstyle(1,2,3)@ 987654322@
-
你的意思是重新采样图像? ,看看这个 [stackoverflow.com/questions/4754594/…
-
我不是 php 专家,也不知道如何正确使用它。你能告诉我如何将这些代码添加到我的 php 文件中吗? @Manikiran 先生
标签: php android image image-processing