Little AnGle
Little AnGle

Reputation: 1

file_put_contents could not store image on server

$path = 'http://fbcdn-profile-a.akamaihd.net/hprofile-ak-snc6/372096_100002534902767_1927052265_n.jpg';
$info = file_put_contents('new/angel.jpg', file_get_contents(urldecode($path)));
echo $info;

It works fine on localhost but it did not work on my website.

Any idea what the problem might be?

Upvotes: 0

Views: 1690

Answers (3)

THE ONLY ONE
THE ONLY ONE

Reputation: 2190

  1. Make sure that there are write permissions to the file in which you are writing
  2. I think the relative path is the problem. It can possible that your local has the path to that file but the path does not exists on server. 3.Please put a forward slash in line $info=file_put_contents('new/angel.jpg', file_get_contents(urldecode($path))); before your "new" folder and try i think this might be a problem

Upvotes: 0

Nour Berro
Nour Berro

Reputation: 560

you need to give a permission (write ) to upload folder

you can do that by the FTP program by using this codes in numeric value :777

Upvotes: 0

Jan Schejbal
Jan Schejbal

Reputation: 4033

  • Check your logs for error messages
  • Does the folder ("new") exist?
  • Are permissions set to allow writing by scripts?
  • Are you sure the error is in file_put_contents? file_get_contents could fail if the host has disallowed url_fopen.
  • unless $path is actually hardcoded, you will probably introduce an arbitrary file disclosure security issue. Make sure you validate your input.

Upvotes: 3

Related Questions