I've built a class that grabs data using cURL from imdb & allmusic and uploads it to a database. I'm having a problem with a method that inserts the data to my db, all the data gets inserted correctly, but when I use the copy()
function the image doesn't get uploaded to the destination folder. If I use copy()
in other methods or from outside my class the image gets placed in the destination folder. for example I have a method that will update the data and copy()
works just fine. I'm pretty confused and probably missing something obvious.
public function insertData() {
if ( !$this->tagExists() ) {
// insert the data if the tag is new.
$data = $this->sortData();
switch (true) {
case $this->is_imdb():
$insertArray = [
"tag" => $this->imdb,
"title" => $this->cleanString( $data["title"] ),
"plot" => $this->cleanString( $data["plot"] ),
"director" => $this->cleanString( $data["director"] ),
"rating" => $this->cleanString( $data["rating"] ),
"metascore" => $this->cleanString( $data["metascore"] ),
"release_date" => $this->cleanString( $data["release_date"] ),
"cast" => $this->formatCast(),
"timestamp" => time()
];
$poster = $data["poster"];
break;
case $this->is_allmusic():
$insertArray = [
"tag" => $this->allmusic,
"artist" => $this->cleanString( $data["artist"] ),
"album" => $this->cleanString( $data["album"] ),
"overview" => $this->cleanString( $data["overview"] ),
"tracklist" => $this->formatTracklist(),
"rating" => $this->cleanString( $data["rating"] ),
"timestamp" => time()
];
$poster = $data["cover"];
break;
}
if ( !$this->imageExists() ) {
copy( $poster, $this->var["imagePath"] );
}
//inserts the data into the database and returns true
return $this->db->insert( $this->var["table"], $insertArray );
} else {
return false;
}
}
this code doesn't work inside the method, but works elsewhere.
if ( !$this->imageExists() ) {
copy( $poster, $this->var["imagePath"] );
}
the full class https://gist.github.com/anonymous/0ef3a8522e83185b552ff36eee1ee3c0