473,414 Members | 1,843 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

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 2516
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($sql) 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($sql) 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($sql) 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($_POST['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($sql) 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($_POST['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
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...
1
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...
2
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...
1
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...
6
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...
0
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...
1
by: nasirmajor | last post by:
dear all, Please any urgent help regarding following code. i have the following code ================================================================= public void Delete(Object sender,...
3
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...
4
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...
2
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.