/    Sign up×
Community /Pin to ProfileBookmark

where is the image going?

Ok I am uploading a picture through a form , it just seem to go through but there is not picture anywhere. None in the database or folder that i assigned to go

it was working before i just made some changes because it seems to be saving the file in the database and i wanted to save just the path because i was told it was the save way but not it is not working anymore

here is the code

[code=php]
<?php

$uploaddir = realpath (“C://Program Files//EasyPHP1-8//home//townsfinder//”);
$uploadfile = $uploaddir . basename($_FILES[‘Picture1’][‘name’]);

if(!empty($_FILES[‘Picture1’]))
{
var_dump($uploaddir);

var_dump($_FILES[‘Picture1’][‘size’]);
var_dump($_FILES[‘Picture1’][‘error’]);
var_dump($_FILES[‘Picture1’][‘type’]);
var_dump($_FILES[‘Picture1’][‘name’]);

}

if (move_uploaded_file($_FILES[‘Picture1’][‘tmp_name’], $uploaddir .$_FILES[‘Picture1’][‘name’]))

{
echo(“File Uploaded”);
}

else

{
echo (“file no uploaded!”);
print_r($_FILES);
echo realpath(‘./’);
}

?>
[/code]

this is my display..

string(44) “C:Program FilesEasyPHP1-8hometownsfinder” int(52440) int(0) string(11) “image/pjpeg” string(16) “bodylanguage.jpg” File Uploaded

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@jabezOct 17.2006 — 
$uploaddir = realpath ("C://Program Files//EasyPHP1-8//home//townsfinder//");

$uploadfile = $uploaddir . basename($_FILES['Picture1']['name']);

...

if (move_uploaded_file($_
FILES['Picture1']['tmp_name'], $uploaddir .$_FILES['Picture1']['name']))

Uploaded[/QUOTE]


Those spaces in the filepaths look a bit suspect to me. You could try building the filenames and pathnames with seperate variables, (and echo them for testing purposes first) before using them as parameters to the move_uploaded_file function. Just use one variable for each parameter in the move_...() function.

I actually used the copy function to upload files to my server, like this:

// build user directory name from ref number

$user_dir_name_1 = 'ref-';

$user_dir_name_1 .= "$ref_number";

// build path to user upload directory

$user_path_1 = UPLOAD_PATH;

$user_path_1 .= $user_dir_name_1;

// check to see if the upload dir exists

// if not, create it now

// build filename

$user_upload_name_1 = $user_path_1;

$user_upload_name_1 .= '/pic1.jpg';

// copy uploaded file_1 to /user-pics/sitename/ref-xxx/ directory

if (copy($temp_name_1, $user_upload_name_1))

{

// change the access mode to read write noexec

chmod($user_upload_name_1, 0600);

echo "<P ALIGN=CENTER> $original_name_1 uploaded successfully! <BR>";

$upload_status = 'OK';

$has_pic1 = 'Y';

}

else

{

echo "Error in uploading $original_name_1 <BR>";

}
×

Success!

Help @franknu 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 6.1,
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: @meenaratha,
tipped: article
amount: 1000 SATS,

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

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...