开发者

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?

开发者 https://www.devze.com 2023-03-20 09:50 出处:网络
I am able to upload file in 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.

I am able to upload file in 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.

In case of delete function should be removed.

$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).


How do I fetch the already uploaded image from the database (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']
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号