/    Sign up×
Community /Pin to ProfileBookmark

how to make server understand the path?

consider that in a program,Users can set one photo in profile.They can also load more photos if they wish. When a photo is uploaded,
things get written in the database but photo is not not saved in the “member_photos” directory. member_photos is in /sdomain/coernet/member_photos and please note that i have changed names for security reasons.
Photo is not displayed and it throws an error which i have pasted below. Its actually a commercial program and it is hosted on a commercial provider and its manual does not say anything about it. Could you please say how I can correct this problem?

.

[code=html]Warning: unlink(../member_photos/file2.JPG) [function.unlink]: No such file or directory in /mnt/web6/32/16/53316/htdocs/sdomain/coernet/pops/photos_show.php on line 116[/code]

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@hastxNov 02.2009 — Why are you getting unlink warnings. You said you are trying to upload. Are you trying to delete the photos?

You might want to post more of your code. The only reason for Unlink warnings is because you are trying to delete something that doesn't exist.
Copy linkTweet thisAlerts:
@feldauthorNov 03.2009 — sorry, i forgot to mention that i get those errors when i try to delete the photos. when I upload photos, no errors are displayed. Please note that as it is a commercial product, I may not post everything. The script generates modifies the name of the photo, (not working ) uploads it into member_photos and inserts the details into database.

[code=php]
$photoTmp = $_FILES['photo']['tmp_id'];

$photoid = $_FILES['photo']['id'];


if (strlen($photoid)>0)

{

$uniqueId = uniqid("");

$photoNewid = $uniqueId.$photoid;

$photoNewid=str_replace(" ","_",$photoNewid);


$dirPath = "../member_photos/";

uploadFile($dirPath,$photoNewid,"photo");


//photo details : insert into database
// certainly works upto this point as database has all the records


[/code]
Copy linkTweet thisAlerts:
@NogDogNov 03.2009 — We'll probably need to see the function definition for the uploadFile() function.
Copy linkTweet thisAlerts:
@criterion9Nov 03.2009 — Did you set the correct permissions on the folder you expect the images to be uploaded to? Also since this is a commercial product on a commercial server why don't you hit up the commercial support for help?
Copy linkTweet thisAlerts:
@feldauthorNov 03.2009 — Thanks for your reply. I was not asked to contact the product developer. I assume that free help is not provided by the developer or that the period for that has expired. I don't get why they use so many global variables neither what $uploaded is intended to do. From what I understand, this script actually works. This means criterion9's suggestion of

setting folder permission would solve the problem. If it cannot be programetically, I will have to contact the hosting provider.

[code=php]

function uploadFile($file-path,$file-name,$FILEBOX)
{
$file=$file-path.$file-name;
$uploaded="TRUE";
global $HTTP_POST_FILES;

if ( isset( $HTTP_POST_FILES[$FILEBOX] ) )
{
if (is_uploaded_file($HTTP_POST_FILES[$FILEBOX]['tmp_name']))
{
if(!copy($HTTP_POST_FILES[$FILEBOX]['tmp_name'], $file-path.$file-name)) {
print "cannot upload photo";
exit;
}
}else{
}
}
}
[/code]
×

Success!

Help @feld spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.25,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...