简体   繁体   English

如何使用 unlink function 在 joomla 中更新和删除文件时删除文件? 并使用取消链接获取要删除的已上传图像?

[英]how to use unlink function to delete file during update and delete in joomla ? and fetch the already uploaded image to be deleted using unlink?

I am able to upload file in joomla.我可以在 joomla 中上传文件。
I want to know if the user is updating images with another image like then the file already present and linked with user id should be replaced or deleted.我想知道用户是否正在使用另一个图像更新图像,例如应该替换或删除已经存在并与用户 ID 链接的文件。
In case of delete function should be removed.如果删除 function 应该被删除。

$src = $file ['tmp_name'];

$dest = JPATH_COMPONENT . DS . "uploads" . DS . $newfilename;

JFile::upload ( $src, $dest );

// update the field greeting_pic //
$result = $model->updateGreetingPic ( $id, $newfilename );

I want to replace the uploaded image if present and replace it with the new one.我想替换上传的图片(如果存在)并将其替换为新图片。
How do I fetch the already uploaded image from the database (MySQL).如何从数据库(MySQL)中获取已上传的图像。

How do I fetch the already uploaded image from the database (MySQL)?如何从数据库(MySQL)中获取已经上传的图像?

$userid = mysql_real_escape_string($_GET['userid']);
$sql = "SELECT imagefilename FROM images WHERE userid = '$userid'";
$result= mysql_query($query) or die (mysql_error());
//note that it may be possible to have multiple images, depending on your app
//and database rules.   
while ($row = mysql_fetch_assoc($result)) { 
  //replace pic in $row['imagefilename']
}

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

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