0
Mới! Lưu câu hỏi hoặc câu trả lời và sắp xếp nội dung yêu thích của bạn. Tìm hiểu thêm.
Learn more.
Tôi sử dụng Bootstrap phương thức với CodeIgnitter 4. Tôi có thể xóa dữ liệu trong cơ sở dữ liệu nhưng không thể tách hình ảnh. Đây là mã của tôi:
Người mẫu :
public function deleteProduct[$id]
{
$query = $this->db->table['produk']->delete[array['kode' => $id]];
return $query;
}
Người điều khiển:
public function delete[]
{
$model = new produkModel[];
$id = $this->request->getPost['kode'];
$produk = $this->produkModel->find[$id];
if [$produk['gambar'] != 'default.png'] {
unlink['imgproduk/' . $produk['gambar']];
}
$model->deleteProduct[$id];
return redirect[]->to['/Tabel_Produk'];
}
Tôi muốn xóa hình ảnh trong thư mục nhưng không xóa mặc định.img
Đã hỏi ngày 21 tháng 3 lúc 6:32Mar 21 at 6:32
4
Sử dụng đường dẫn thư mục hoàn chỉnh để xóa/truy cập hình ảnh thông qua PHP bằng cách sử dụng $ _server ['Document_root'] để nhận đường dẫn máy chủ.
public function delete[]{
$model = new produkModel[];
$id = $this->request->getPost['kode'];
$produk = $this->produkModel->find[$id];
if [$produk['gambar'] != 'default.png'] {
unlink[$_SERVER['DOCUMENT_ROOT'].'/imgproduk/' . $produk['gambar']];
}
$model->deleteProduct[$id];
return redirect[]->to['/Tabel_Produk'];
}
Đã trả lời ngày 22 tháng 3 lúc 19:53Mar 22 at 19:53
FarhanfarhanFarhan
1.4532 huy hiệu vàng15 Huy hiệu bạc20 Huy hiệu đồng2 gold badges15 silver badges20 bronze badges
2
9 năm trước
[Php 4, Php 5, Php 7, Php 8] — Deletes a file
Khóc - xóa một tệp
Sự mô tả[string $filename
, ?resource $context
= null
]: bool
Hủy liên kết [Chuỗi $filename
,? Tài nguyên $context
= null
]: Bool
Thông số filename
Đường dẫn đến tệp.rmdir[] has to be used instead.
Nếu tệp là một Symlink, Symlink sẽ bị xóa. Trên Windows, để xóa Symlink vào một thư mục, RMDIR [] phải được sử dụng thay thế. context
resource.
Một tài nguyên luồng ngữ cảnh.
Trả về giá trịtrue
on success or false
on failure.
Trả về true
khi thành công hoặc false
về thất bại.
7.3.0 | Sự mô tảunlink[] files with handles in use, while formerly that would fail. However, it is still not possible to re-create the unlinked file, until all handles to it have been closed. |
Hủy liên kết [Chuỗi $filename
,? Tài nguyên $context
= null
]: Bool
Thông sốunlink[] usage
public function delete[]
{
$model = new produkModel[];
$id = $this->request->getPost['kode'];
$produk = $this->produkModel->find[$id];
if [$produk['gambar'] != 'default.png'] {
unlink['imgproduk/' . $produk['gambar']];
}
$model->deleteProduct[$id];
return redirect[]->to['/Tabel_Produk'];
}
0 filename
- Đường dẫn đến tệp.
Nếu tệp là một Symlink, Symlink sẽ bị xóa. Trên Windows, để xóa Symlink vào một thư mục, RMDIR [] phải được sử dụng thay thế. ¶
context
public function delete[]
{
$model = new produkModel[];
$id = $this->request->getPost['kode'];
$produk = $this->produkModel->find[$id];
if [$produk['gambar'] != 'default.png'] {
unlink['imgproduk/' . $produk['gambar']];
}
$model->deleteProduct[$id];
return redirect[]->to['/Tabel_Produk'];
}
1 public function delete[]
{
$model = new produkModel[];
$id = $this->request->getPost['kode'];
$produk = $this->produkModel->find[$id];
if [$produk['gambar'] != 'default.png'] {
unlink['imgproduk/' . $produk['gambar']];
}
$model->deleteProduct[$id];
return redirect[]->to['/Tabel_Produk'];
}
2 public function delete[]
{
$model = new produkModel[];
$id = $this->request->getPost['kode'];
$produk = $this->produkModel->find[$id];
if [$produk['gambar'] != 'default.png'] {
unlink['imgproduk/' . $produk['gambar']];
}
$model->deleteProduct[$id];
return redirect[]->to['/Tabel_Produk'];
}
3Một tài nguyên luồng ngữ cảnh. ¶
11 năm trước
public function delete[]
{
$model = new produkModel[];
$id = $this->request->getPost['kode'];
$produk = $this->produkModel->find[$id];
if [$produk['gambar'] != 'default.png'] {
unlink['imgproduk/' . $produk['gambar']];
}
$model->deleteProduct[$id];
return redirect[]->to['/Tabel_Produk'];
}
4 public function delete[]
{
$model = new produkModel[];
$id = $this->request->getPost['kode'];
$produk = $this->produkModel->find[$id];
if [$produk['gambar'] != 'default.png'] {
unlink['imgproduk/' . $produk['gambar']];
}
$model->deleteProduct[$id];
return redirect[]->to['/Tabel_Produk'];
}
5 public function delete[]
{
$model = new produkModel[];
$id = $this->request->getPost['kode'];
$produk = $this->produkModel->find[$id];
if [$produk['gambar'] != 'default.png'] {
unlink['imgproduk/' . $produk['gambar']];
}
$model->deleteProduct[$id];
return redirect[]->to['/Tabel_Produk'];
}
6 public function delete[]
{
$model = new produkModel[];
$id = $this->request->getPost['kode'];
$produk = $this->produkModel->find[$id];
if [$produk['gambar'] != 'default.png'] {
unlink['imgproduk/' . $produk['gambar']];
}
$model->deleteProduct[$id];
return redirect[]->to['/Tabel_Produk'];
}
7 public function delete[]
{
$model = new produkModel[];
$id = $this->request->getPost['kode'];
$produk = $this->produkModel->find[$id];
if [$produk['gambar'] != 'default.png'] {
unlink['imgproduk/' . $produk['gambar']];
}
$model->deleteProduct[$id];
return redirect[]->to['/Tabel_Produk'];
}
8 public function delete[]
{
$model = new produkModel[];
$id = $this->request->getPost['kode'];
$produk = $this->produkModel->find[$id];
if [$produk['gambar'] != 'default.png'] {
unlink['imgproduk/' . $produk['gambar']];
}
$model->deleteProduct[$id];
return redirect[]->to['/Tabel_Produk'];
}
3Trả về giá trị ¶
8 năm trước
public function delete[]{
$model = new produkModel[];
$id = $this->request->getPost['kode'];
$produk = $this->produkModel->find[$id];
if [$produk['gambar'] != 'default.png'] {
unlink[$_SERVER['DOCUMENT_ROOT'].'/imgproduk/' . $produk['gambar']];
}
$model->deleteProduct[$id];
return redirect[]->to['/Tabel_Produk'];
}
0 public function delete[]{
$model = new produkModel[];
$id = $this->request->getPost['kode'];
$produk = $this->produkModel->find[$id];
if [$produk['gambar'] != 'default.png'] {
unlink[$_SERVER['DOCUMENT_ROOT'].'/imgproduk/' . $produk['gambar']];
}
$model->deleteProduct[$id];
return redirect[]->to['/Tabel_Produk'];
}
1 public function delete[]
{
$model = new produkModel[];
$id = $this->request->getPost['kode'];
$produk = $this->produkModel->find[$id];
if [$produk['gambar'] != 'default.png'] {
unlink['imgproduk/' . $produk['gambar']];
}
$model->deleteProduct[$id];
return redirect[]->to['/Tabel_Produk'];
}
3
Federico tại Poisonfx dot com ¶ ¶
11 năm trước
public function delete[]{
$model = new produkModel[];
$id = $this->request->getPost['kode'];
$produk = $this->produkModel->find[$id];
if [$produk['gambar'] != 'default.png'] {
unlink[$_SERVER['DOCUMENT_ROOT'].'/imgproduk/' . $produk['gambar']];
}
$model->deleteProduct[$id];
return redirect[]->to['/Tabel_Produk'];
}
3 public function delete[]{
$model = new produkModel[];
$id = $this->request->getPost['kode'];
$produk = $this->produkModel->find[$id];
if [$produk['gambar'] != 'default.png'] {
unlink[$_SERVER['DOCUMENT_ROOT'].'/imgproduk/' . $produk['gambar']];
}
$model->deleteProduct[$id];
return redirect[]->to['/Tabel_Produk'];
}
4 public function delete[]
{
$model = new produkModel[];
$id = $this->request->getPost['kode'];
$produk = $this->produkModel->find[$id];
if [$produk['gambar'] != 'default.png'] {
unlink['imgproduk/' . $produk['gambar']];
}
$model->deleteProduct[$id];
return redirect[]->to['/Tabel_Produk'];
}
3Chris tại Vibenewmedia dot com ¶
18 năm trước
public function delete[]{
$model = new produkModel[];
$id = $this->request->getPost['kode'];
$produk = $this->produkModel->find[$id];
if [$produk['gambar'] != 'default.png'] {
unlink[$_SERVER['DOCUMENT_ROOT'].'/imgproduk/' . $produk['gambar']];
}
$model->deleteProduct[$id];
return redirect[]->to['/Tabel_Produk'];
}
6 public function delete[]{
$model = new produkModel[];
$id = $this->request->getPost['kode'];
$produk = $this->produkModel->find[$id];
if [$produk['gambar'] != 'default.png'] {
unlink[$_SERVER['DOCUMENT_ROOT'].'/imgproduk/' . $produk['gambar']];
}
$model->deleteProduct[$id];
return redirect[]->to['/Tabel_Produk'];
}
7 public function delete[]
{
$model = new produkModel[];
$id = $this->request->getPost['kode'];
$produk = $this->produkModel->find[$id];
if [$produk['gambar'] != 'default.png'] {
unlink['imgproduk/' . $produk['gambar']];
}
$model->deleteProduct[$id];
return redirect[]->to['/Tabel_Produk'];
}
3PD ¶ ¶
14 năm trước
public function delete[]{
$model = new produkModel[];
$id = $this->request->getPost['kode'];
$produk = $this->produkModel->find[$id];
if [$produk['gambar'] != 'default.png'] {
unlink[$_SERVER['DOCUMENT_ROOT'].'/imgproduk/' . $produk['gambar']];
}
$model->deleteProduct[$id];
return redirect[]->to['/Tabel_Produk'];
}
9$filename
0
$filename
1
$filename
2
$filename
3
public function delete[]
{
$model = new produkModel[];
$id = $this->request->getPost['kode'];
$produk = $this->produkModel->find[$id];
if [$produk['gambar'] != 'default.png'] {
unlink['imgproduk/' . $produk['gambar']];
}
$model->deleteProduct[$id];
return redirect[]->to['/Tabel_Produk'];
}
3
gotdalife tại gmail dot com ¶
14 năm trước
$filename
5
$filename
6
$filename
7
public function delete[]
{
$model = new produkModel[];
$id = $this->request->getPost['kode'];
$produk = $this->produkModel->find[$id];
if [$produk['gambar'] != 'default.png'] {
unlink['imgproduk/' . $produk['gambar']];
}
$model->deleteProduct[$id];
return redirect[]->to['/Tabel_Produk'];
}
3gotdalife tại gmail dot com ¶
8 năm trước
$filename
9
Eric ¶ ¶
Divivent76+Spam tại Gmail Dot Com ¶
$context
0
2 tháng trước đây ¶
llmll tại gmx dot de ¶
$context
1
$context
2
public function delete[]
{
$model = new produkModel[];
$id = $this->request->getPost['kode'];
$produk = $this->produkModel->find[$id];
if [$produk['gambar'] != 'default.png'] {
unlink['imgproduk/' . $produk['gambar']];
}
$model->deleteProduct[$id];
return redirect[]->to['/Tabel_Produk'];
}
37 năm trước ¶
Keatran ¶
$context
4
$context
5
public function delete[]
{
$model = new produkModel[];
$id = $this->request->getPost['kode'];
$produk = $this->produkModel->find[$id];
if [$produk['gambar'] != 'default.png'] {
unlink['imgproduk/' . $produk['gambar']];
}
$model->deleteProduct[$id];
return redirect[]->to['/Tabel_Produk'];
}
32 năm trước ¶
Alex, Marrch CA ' tại ¶
$context
7