Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

picture url upload or server choice

Status
Not open for further replies.

wudz

Programmer
Mar 28, 2001
135
0
0
GB
Hi,
Now do I need help here. i have a third party script that allows the user to upload a picture from their computer to the site.
What I would like to do depending on the situation is IF certain criteria are met then a choice to allow them to browse their computer or a server side folder to choose a picture to use..
The problem is being a newbie I do not fully understand where the changes have to be made for the the choice for the user of the user computer or server folder in the browser popup window.
I now that a java script controls the popup, but where does the picture url section allow my proposed alteration.

I think this is the HTML section....


<!------------------------- URL of photo ------------------>
<?
if(!empty($TPL_pict_URL_value)) {
?>
<TR>
<TD WIDTH="352" VALIGN="middle"


ALIGN="right"><? print $std_font; ?>
<B> <? print $MSG_938; ?> </B> </TD>
<TD WIDTH="535" valign= "top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<INPUT TYPE=HIDDEN NAME=upd_pict_url VALUE="<? print $sessionVars["SELL_pict_url"]; ?>">
<? print $std_font; ?> <? print $TPL_pict_URL_value; ?> </TD>
</TR>

<?
}
?>



and this the PHP....

// $sessionVars=array();
if(isset($upd_pict_url)) {

$sessionVars["SELL_pict_url"] = $upd_pict_url;
$sessionVars["SELL_file_uploaded"] = $imgtype;
}

if($imgtype==1 && !empty($_FILES['userfile']['name']) && $_FILES['userfile']['name'] != "none") {
// move uploaded file in right place
//set uploaded file path session variable
//empty linked file path session variable
$inf = GetImageSize ($_FILES['userfile']['tmp_name']);
$er = false;
// make a check
if ($inf) {
$inf[2] = intval($inf[2]); // check for uploaded file type
if ( $inf[2]<1 || $inf[2]>3 ) {
$er = true;
$ERR = "ERR_602";
} elseif ( intval($userfile_size) > $SETTINGS['maxuploadsize'] ) {
$er = true;
$ERR = "ERR_603";
} else {
switch($inf[2]) {
case 1: $ext=".gif";
break;
case 2: $ext=".jpg";
break;
case 3: $ext=".png";
break;
}
$uploaded_filename = $auction_id.$ext;
$fname = $image_upload_path.$uploaded_filename;
if (file_exists($fname)) {
unlink ($fname);
}
move_uploaded_file($_FILES['userfile']['tmp_name'],$fname);
chmod($fname,0666);
$sessionVars["SELL_pict_url"] = $uploaded_filename;
$sessionVars["SELL_file_uploaded"] = $imgtype;
}
} else {
$ERR = "ERR_602";
$er = true;
}
} elseif($imgtype==0 && !empty($pict_url)) {
//control if uploaded file path session variable
//if yes delete already uploaded files
//empty uploaded file path session variable
//if ($sessionVars["SELL_file_uploaded"]) {
// unlink($image_upload_path.$sessionVars["SELL_pict_url"]);
//}
$ext=strtolower(substr($pict_url,-3));
if($ext!="gif" && $ext!="jpg" && $ext!="png") {
$ERR = "ERR_602";
} else {
$sessionVars["SELL_pict_url"] = $pict_url;
$sessionVars["SELL_file_uploaded"] = $imgtype;

now all this is heavey going for me, a mere mortal...help from the brains amongst you is appreciated..

Cheers

John
FLASH is my game.........
 
hi there

i'd approach this with a slightly different philosophy

1. allow users to upload images to a server directory
2. allow users to choose from a list of server files

i would not use javascript for this - it's eminently possible with just server side code.

key question is what do you want the users to do with the image once it is chosen.

i have written a script that you might easily adapt. You can find it at
it stores the binary in a database which is something i disagree with but this is easily changeable.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top