473,788 Members | 2,652 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to delete a file in my web server via php

Hi to all, that's my question I have mysql database and a web page to
upload files to my webpage, I know how to delete them from the
database, but didnt find the code to delete them from the web server.
Please help me with this code.

Regards

Marcelo Fabiani

Jan 22 '07 #1
7 2531
marce1972 wrote:
Hi to all, that's my question I have mysql database and a web page to
upload files to my webpage, I know how to delete them from the
database, but didnt find the code to delete them from the web server.
Please help me with this code.
The only way to do this through HTTP is to create a remote script that
accepts parameters and uses these to select and delete the file. There's
also a HTTP DELETE method, but I have never encountered a server which
supports it.
JW
Jan 22 '07 #2
Janwillem Borleffs schreef:
marce1972 wrote:
>Hi to all, that's my question I have mysql database and a web page to
upload files to my webpage, I know how to delete them from the
database, but didnt find the code to delete them from the web server.
Please help me with this code.

The only way to do this through HTTP is to create a remote script that
accepts parameters and uses these to select and delete the file. There's
also a HTTP DELETE method, but I have never encountered a server which
supports it.
JW
shortest way :
@unlink($file);

Make sure to check the input first

--
Arjen
http://www.hondenpage.com
Jan 22 '07 #3
Janwillem Borleffs wrote:
The only way to do this through HTTP is to create a remote script that
accepts parameters and uses these to select and delete the file. There's
also a HTTP DELETE method, but I have never encountered a server which
supports it.
Apache does, though you need to do a lot of setup to get it to work.
WebDAV is a bit easier to set up, and better supported at the client end.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

Jan 22 '07 #4

Floortje wrote:
Janwillem Borleffs schreef:
marce1972 wrote:
Hi to all, that's my question I have mysql database and a web page to
upload files to my webpage, I know how to delete them from the
database, but didnt find the code to delete them from the web server.
Please help me with this code.
The only way to do this through HTTP is to create a remote script that
accepts parameters and uses these to select and delete the file. There's
also a HTTP DELETE method, but I have never encountered a server which
supports it.
JW

shortest way :
@unlink($file);

Make sure to check the input first

--
Arjen
http://www.hondenpage.com
Do I rite this on my php code as you wrote it?

$nom=$_POST['numero'];
$sql="DELETE FROM canciones WHERE idcancion='$nom ';";
mysql_query($sq l) or die ("problema con borrado");
$arch=$_POST['ref'];
@unlink($arch);

Is this correct
Thanks I'll download the other option webdav too to see if it works

regards

Marcelo

Jan 22 '07 #5
marce1972 wrote:
Do I rite this on my php code as you wrote it?

$nom=$_POST['numero'];
$sql="DELETE FROM canciones WHERE idcancion='$nom ';";
mysql_query($sq l) or die ("problema con borrado");
$arch=$_POST['ref'];
@unlink($arch);

Is this correct
Thanks I'll download the other option webdav too to see if it works
No, as Arjen already pointed out: check the input. This means you should
check the value of $_POST['ref'], because if you don't the user will be
able to delete any file the webserver has writing rights to.

Ruben.
Jan 22 '07 #6
Ruben van Engelenburg schreef:
marce1972 wrote:
>Do I rite this on my php code as you wrote it?

$nom=$_POST['numero'];
$sql="DELETE FROM canciones WHERE idcancion='$nom ';";
mysql_query($sq l) or die ("problema con borrado");
$arch=$_POST['ref'];
@unlink($arch);

Is this correct
Thanks I'll download the other option webdav too to see if it works

No, as Arjen already pointed out: check the input. This means you should
check the value of $_POST['ref'], because if you don't the user will be
able to delete any file the webserver has writing rights to.
One way to do it:
check if page is listed in the db
$sql = "SELECT id,page FROM $table WHERE id = '".intval($_POS T['id'])."'";

if that query gives one result then execute your code
--
Arjen
http://www.hondenpage.com
Jan 22 '07 #7
Floortje schreef:
Ruben van Engelenburg schreef:
>marce1972 wrote:
>>Do I rite this on my php code as you wrote it?

$nom=$_POST['numero'];
$sql="DELETE FROM canciones WHERE idcancion='$nom ';";
mysql_query($sq l) or die ("problema con borrado");
$arch=$_POST['ref'];
@unlink($arch);

Is this correct
Thanks I'll download the other option webdav too to see if it works

No, as Arjen already pointed out: check the input. This means you
should check the value of $_POST['ref'], because if you don't the user
will be able to delete any file the webserver has writing rights to.

One way to do it:
check if page is listed in the db
$sql = "SELECT id,page FROM $table WHERE id = '".intval($_POS T['id'])."'";

if that query gives one result then execute your code
And I mean execute your code with the results from the query :-) not
from the user input.
--
Arjen
http://www.hondenpage.com
Jan 22 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1836
by: Peter A. Schott | last post by:
Got a strange scenario going on here in that I could have sworn this worked yesterday. I am issuing binary retrieval calls to an FTP server, writing to a file, close the file, then removing the file from the remote site. When I do this, I end up with 0 byte files. I was hoping to avoid parsing a list of remote and local files and matching them up that way because it would be easier to remove on successful retrieve. I'm including some...
1
8906
by: Andrew DeFaria | last post by:
I created the following .sql file to demonstrate a problem I'm having. According to the manual: If |ON DELETE CASCADE| is specified, and a row in the parent table is deleted, then InnoDB automatically deletes also all those rows in the child table whose foreign key values are equal to the referenced key value in the parent row. However:
2
8807
by: Ryan | last post by:
I have a table in my database on SQL Server which holds a file name that refers to a file that is stored on the server. I would like to create a trigger to delete this file from the server if the row in the table is deleted. I have been trying to use this command in a trigger (<filename> is the name and path of the file): xp_cmdshell "delete <filename>" If some one could please help I would appreciate it very much. I would love a...
1
1908
by: Matt Hamilton | last post by:
I have a simple image gallery where I want to allow users to delete files. The problem I have is that after an image is displayed in the browser, I am not able to delete the file because "The process cannot access the file ... It is being used by another process". I also get this error when trying to delete through explorer on the server. I can delete the file if I stop the Web Server service... Is there a way around this? Here is the...
6
2586
by: I am Sam | last post by:
I keep getting this error and I don't know why: The path is too long after being fully qualified. Make sure path is less than 260 characters. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.IO.PathTooLongException: The path is too long
0
2851
by: smanisankar | last post by:
hi, the following is the full page code for uploading a file to server. since i got no idea to overwrite the file, i want delete the file if the file is already uploaded. i got the folder name and filename of the file to delete from the request.QueryString("path") so i got the above error when i try to delete the file before upload. Please anyone help me to solve out from this error. <%@ Import Namespace="System.IO" %>
1
2364
by: nasirmajor | last post by:
dear all, Please any urgent help regarding following code. i have the following code ================================================================= public void Delete(Object sender, DataGridCommandEventArgs e) { 1 int Sid2 = (int)l.DataKeys;
3
3282
by: Arpan | last post by:
A Form has a FileUpload, 2 Buttons & a TextBox web server controls. Using the FileUpload control, I want to give users the provision to move & delete files that DO NOT exist in C:\Inetpub\wwwroot (i.e. the root directory). This is the code: <script runat="server"> Sub MoveFile(ByVal obj As Object, ByVal ea As EventArgs) File.Move(fudFileSource.FileName, txtFileDest.Text) 'File.Move("F:\4.jpg", "C:\4.jpg") End Sub
4
25181
by: Sailor1877 via AccessMonster.com | last post by:
I've been reading all the threads about problems with LDB files but my specific problem doesn't seem to be addressed. I have a back end database on a server that I'm unable to run Compact and Repair on because the LDB file is still present. It tells me it is being used by a user "Admin" on my machine (a fact that is echoed when I open the LDB file in Notepad.) Unfortunately there is no username "Admin" on the network. When I try to...
2
15011
by: SCPOS | last post by:
Cannot delete X: It is being used by another person or program. Close any programs that might be using the file and try again. Of course I have tried closing any programs I know of that may be using the file (used X because the filename does not matter...it is a specific log file name to the application). I am logged onto a Windows Server 2003 computer that acts as a server for a LAN, but is physically joined to a domain. The local...
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10366
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7517
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5399
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4070
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3674
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.