Jump to content

opening and deleting files


tallberg

Recommended Posts

Hi i want to delete file in a certain dir.

When i use the following code i am unable to open file in the dir call uploaded.

If this is a permision thing, how do i changing the dir and file permissions on a wamp set up on windows?

$myFile = "dfd.jpg";
$fh = fopen(uploaded/$myFile, 'w') or die("can't open file");
//fclose($fh);

//unlink($myFile);

This the error message.
Warning: Division by zero in C:\wamp\www\httpdocs\catalogue2\unlink.php on line 10
can't open file

Thanks in advance
Link to comment
https://forums.phpfreaks.com/topic/30762-opening-and-deleting-files/
Share on other sites

Change this line:
[code]<?php
$fh = fopen(uploaded/$myFile, 'w') or die("can't open file");
?>[/code]

to
[code]<?php
$fh = fopen('uploaded/' . $myFile, 'w') or die("can't open file");
?>[/code]

The problem is that you didn't quote the fixed part of the filename and PHP thought you were trying to perform a division statement.

Ken

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.