hello, i have a probelm where i want to update my image in database using unlink(). The error is Warning: unlink(images/481933.jpg): No such file or directory. I try search the solution but nothing can solve my probelm. anyone can help me? thank you in advanced. this is my code:

$upload_dir='images/';

$imgExt=strtolower(pathinfo($images,PATHINFO_EXTENSION));

$valid_extensions=array('jpeg', 'jpg', 'png', 'gif', 'pdf');

$picProfile=rand(1000, 1000000).".".$imgExt;

unlink($upload_dir.$edit_row['prod_img']);

move_uploaded_file($tmp_dir, $upload_dir.$picProfile);

$stmt=$db_conn->prepare('UPDATE product SET prod_name=:prod_name, category=:category, prod_img=:prod_img, unit_price=:price, stock=:stock, min_limit=:min_limit, weight=:weight, description=:description, packaging=:packaging, size=:size, retail_price=:retail, agent_price=:agent WHERE prod_id=:prod_id');
Christine_14 commented: Is it resolved? +0

Does the file you are trying to delete actually exist?

You are specifying a relative path. That means that the images folder should exist as a subdirectory within wherever the location of this PHP file is. Try changing the $upload_dir to an absolute path such as /home/username/images/.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.