PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 1st, 2000, 08:18 PM
Ryan Ryan is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Posts: 19 Ryan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I am setting up a virtual squadron database. I want useres to be able to add their logo to there entry. So Imade it so that they type te URL and it use the <.image src="uRL here".> command in HTML

Is there any way to limit the size of the image or do I have to have them upload it...and if so how do I do that?

Or is tere any way to detect the image size...then resize it smaller maintaininng the smae aspect ratio?
Thanks,
Ryan

[This message has been edited by Ryan (edited April 01, 2000).]

Reply With Quote
  #2  
Old April 2nd, 2000, 12:42 AM
ecchu79 ecchu79 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2000
Posts: 6 ecchu79 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to ecchu79
Are you having the users upload the file with a form? if so, you can use the following form, and you can set the max size the users may upload:

<form enctype="multipart/form-data" action="" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="15000">
<input name="uploaded" type="file">
<input type="submit" value="Upload">
</form>

You may use the getimagesize() function to get information about the image uploaded. It puts information into an array, and you can access different things. For example, say you did something liek this:
$image_size = getimagesize($image_file)

then ur width would be $image_size[0] and your height would be $image_size[1]. There is also other informatino stored in this array. You can find all the documentation on php.net. To change hte size, and maintain the aspect ratio, you could do something like this:

if ($image_size[0] > 350) {
$width = 350;
$height = (350 * $image_size[1])/$image_size[0];
} else {
$width = $image_size[0];
$height = $image_size[1];
}

This will resize any image that's wider than 350 px. Then you would do something liek this:

echo "<img src='image.gif' width=$width height=$height alt='' border='1'>

Hope this helps

Reply With Quote
  #3  
Old April 2nd, 2000, 10:08 AM
Ryan Ryan is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Posts: 19 Ryan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
thanks ill try it!

Ryan

Reply With Quote
  #4  
Old April 2nd, 2000, 03:34 PM
Ryan Ryan is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Posts: 19 Ryan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I cant get it to work

Here is my Code:
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
<TITLE>The 54th Screamin Devils - Squadrons Database</TITLE>
<META name="description" content=""><META name="keywords" content="">
<META name="generator" content="CuteHTML">

<style>
A:Link {background:#003344; color:#F5F5DC;text-decoration:none;}

A:Visited {background:#003344; color:#F5F5DC;text-decoration:none;}

A:Hover {background:#990000; color:#F5F5DC; text-decoration:none;}
</style>
</HEAD>

<BODY BGCOLOR="#8ba68b" TEXT="#000000">

<TABLE BORDER=0 CELLSPACING=0 width="100%" cellpadding="0">
<TR>
<TD COLSPAN=2 background="http://www.cfsquad.com/menu-blanks.gif"><DIV ALIGN="right"><img src="http://www.cfsquad.com/header.gif"></div></TD>
</TR>

<tr>
<TD bgcolor="#003344" width="15%" valign="top">


<!-- Menu --> <? virtual("/manu.shtml"); ?>


<br>

<font face="Arial" size="1" color="beige"><!-- counter --> <!--#exec cgi="/cgi-bin/counter.pl"--></font>

</td>

<TD valign="top" bgcolor="8ba68b">

<!-- Main Section -->

<div align="left"><img src="http://www.cfsquad.com/cor1.gif"></div>
<div align="center" ><FONT FACE="Arial" SIZE=1 COLOR="#000000">


<?

//
// Connect to local mySQL database
//
$db = mysql_connect("localhost", "online", "*****");

//
// Select your database
//
mysql_select_db("online", $db);

//
// Message to display when adding is complete
//
$msgdone = "<font face="Arial" size="2" color="Black">Success! Your Squadron has been added to the Database</font> <br>Your Listing is below.<br> Click <a href="http://www.cfsquad.com/php/view.php3?view=all">here</a> to view the rest of the Database";

//
// using a query from te form helps out somewhat
//
if ($add == "yes")
{
//
// this inserts a new "profile" into the fields selected. I automatically increments the ID number
//
mysql_query("INSERT INTO squad_db (ID, SQUADNAME, CONTACT, URL, SHIST, CO, PASS) VALUES (0, '$squadname', '$contact', '$url', '$shist', '$co', '$pass')");

//
// Prints message if all goes well
//
print("$msgdonen");
}

//
// Select a squadron from the server with the query $id=$id
//

$image_size = getimagesize($logo);

$imageName = basename($logo);


if ($image_size[0] > 100)
{
$width = 100;
$height = (100 * $image_size[1])/$image_size[0];
}
else
{
$width = $image_size[0];
$height = $image_size[1];
}

if($copy)
{
copy($logo, "/home/online/www/images/" . $ImageName);
}
elseif(!($copy))
{
print("No file of function specified for copy!n");
}

?>


<?
print "<table border="1" cellpadding="0" align="center" width="60%">n";
print "<tr><td rowspan="6">";
print "<img src="$logo"></td>";
print "<td><font face="Arial" size="2">Squadron Name:</font></td><td align="right"><font face="Arial" size="2">$squadname</font></td>n";
print "</tr><tr>n";
print "<td><font face="Arial" size="2">Squadron Contact:</font></td><td align="right"><font face="Arial" size="2"><a href="mailto:$contact">$co</a></font></td>n";
print "</tr><tr>n";
print "<td><font face="Arial" size="2">Squadron URL:</font></td><td align="right"><font face="Arial" size="2"><a href="$url">$url</a></font></td>n";
print "</tr><tr>n";
print "<td><font face="Arial" size="2">Short History:</font></td><td align="right"><font face="Arial" size="2">$shist</font></td>n";
print "</tr><tr>n";
print "<td><font face="Arial" size="2">C/O:</font></td><td align="right"><font face="Arial" size="2">$co</font></td>n";
print "</tr><tr>n";
print "<td><font face="Arial" size="2">Password:</font></td><td align="right"><font face="Arial" size="2">$pass</font></td>n";
print "</tr>";

print "</table>n";

mail("$contact","Squadron Added",
"Hello $co

The Following information has been Submitted to the Squadrons Database at Cfsquad.com

Squadron Name:$squadname
Squadron Contact: $contact
Squadron URL: $URL
Short History: $SHIST
Commanding Officer: $CO
Logo: $logo
Password: $Pass This is not in use yet. When the editing feature is added you will need this to do so.)

Thankyou,
CFSquad.com
webmaster@cfsquad.com", "From: webmaster@cfsquad.com");
?>
<br>

</td></tr>
<tr><td valign="bottom"><img src="http://www.cfsquad.com/bottom.gif" width="150"></td>
<td></td>
</tr>
</table>
</div>

</BODY>
</HTML>
[/code]

and to add the sqad:
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>

<HTML>
<HEAD>
<TITLE>The 54th Screamin Devils - Squadrons Database</TITLE>


<style>
A:Link {background:#003344; color:#F5F5DC;text-decoration:none;}

A:Visited {background:#003344; color:#F5F5DC;text-decoration:none;}

A:Hover {background:#990000; color:#F5F5DC; text-decoration:none;}
</style>
</HEAD>

<BODY BGCOLOR="#8ba68b" TEXT="#000000">

<TABLE BORDER=0 CELLSPACING=0 width="100%" cellpadding="0">
<TR>
<TD COLSPAN=2 background="http://www.cfsquad.com/menu-blanks.gif"><DIV ALIGN="right"><img src="http://www.cfsquad.com/header.gif"></div></TD>
</TR>

<tr>
<TD bgcolor="#003344" width="15%" valign="top">


<!-- Menu --> <? virtual("/manu.shtml"); ?>


<br>

<font face="Arial" size="1" color="beige"><!-- counter --> <!--#exec cgi="/cgi-bin/counter.pl"--></font>

</td>

<TD valign="top" bgcolor="8ba68b">

<!-- Main Section -->

<div align="left"><img src="http://www.cfsquad.com/cor1.gif"></div>
<div align="center" >

<b><font face="Arial" size="3" color="#FFFFFF">Add Your Squad to the Database!</font>
</b>
<FONT FACE="Arial" SIZE=1 COLOR="#000000">

<?
//
// This page has no PHP whatsoever except for this comment
//
?>
<form name="addsquad" action="addsquad.php3?add=yes ©" method="POST" enctype="multipart/form-data">
<table border="0" cellpadding="2 cellspacing="0"><tr><td>

<b><font face="Arial" size="2">Squad Name:</font></b> </td><td> <input type="text" name="squadname"><br>
</tr><tr><td><b><font face="Arial" size="2">Contact Email:</font></b></td><td> <input type="text" name="contact"><br>
</tr><tr><td><font face="Arial" size="2"><b>URL:</b></font></td><td> <input type="text" name="url"><br>
</tr><tr><td><font face="Arial" size="2"><b>Short Hist:</b></font></td><td> <input type="text" name="shist"><br>
</tr><tr><td><font face="Arial" size="2"><b>C/O:</b></font> </td><td> <input type="text" name="co"><br>
</tr><tr><td><font face="Arial" size="2"><b>Logo: </b><font size="1">(No larger than 140X100)</font>:</font></td><td><input type="hidden" name="MAX_FILE_SIZE" value="15000">
<input name="logo" type="file">
</tr><tr><td><font face="Arial" size="2"><b>Password</b>:</font></td><td><input type="text" name="pass"><br></tr></table>
<input type="submit" value="Add Squad">
</form>

<br>

</td></tr>
<tr><td valign="bottom"><img src="http://www.cfsquad.com/bottom.gif" width="150"></td>
<td><font face="Arial" size="1">Copyright © 199-2000 54th Screamin Devils</font></td>
</tr>
</table>
</div>

</BODY>
</HTML>

[/code]

Any suggestions??

Thanks,
Ryan


[This message has been edited by Ryan (edited April 02, 2000).]

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > PHP/Databse


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT