Jump to content

unlink issue?


Miko

Recommended Posts

Hi,

 

I have a function that resides in a class, this function deletes a file in a specific folder.

This works, the file is deleted but I get the warning that he can't find the file in the folder.

 

So here's the error:

 

Warning: unlink(/Applications/MAMP/htdocs/wordpress/wp-content/plugins/flashplayer/player/songs/14-i_cant_go_on_ill_go_on_feat._vanessa_hudgens-everything_i_own.mp3) [function.unlink]: No such file or directory in /Applications/MAMP/htdocs/wordpress/wp-content/plugins/flashplayer/xml.php on line 122

 

And here's the code:

 

Delete function:

function remove_mp3_file(){

	$target_path = dirname(__FILE__)."/player/songs/";
	unlink($target_path.$this->filename);

}

 

function that calls the remove function:

 

function remove_xml_item(){

	//$this->open_xml_playlist();

	$xml = new DOMDocument('1.0', 'UTF-8');
	$xml->preserveWhiteSpace = false;
	$file = dirname(__FILE__)."/player/music.xml";
	$xml->load($file);

	$xpath = new DOMXPath($xml);
	$query = '//song[title="'.htmlentities($this->title).'" and artist = "'.htmlentities($this->artist).'" ]';
	$entries = $xpath->query( $query );

	foreach( $entries as $entry ){

		$entry->parentNode->removeChild($entry);

	}

	$savefile = $xml->save($file);

	$remove_file = $this->remove_mp3_file();

	if( (!$savefile) && (!$remove_file) ){
		return false;
	}elseif( ($savefile) && ($remove_file) ){
		return true;
	}

}

 

First I thought that it was I set a variable that calls the delete function and then I use a if statement for this, but it wasn't that.

 

Anyone an idea?

 

Thanks!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.