Jump to content

justsomeguy

Moderator
  • Posts

    31,575
  • Joined

  • Last visited

  • Days Won

    77

Posts posted by justsomeguy

  1. OK, I've done almost this exact same thing myself, except the files are stored in a database.I assume you already have all the code for accepting the upload and saving the uploaded file somewhere. If not, let me know, I can help with that part too. I'll try to include all of the relevant code, but if there's anything you don't understand let me know.BTW: GIF images had copyright issues when I wrote this code, and so I converted all GIF files to JPEG.

    //define max thumbnail size (width or height, whatever is the larger dimension)$th_size = 100; // in pixels$filename = $_FILES['newimg']['tmp_name'];if (isset($filename) && is_uploaded_file($filename)){  $data = fread(fopen($filename, "rb"), filesize($filename)); //the bytes of the image file, stored in a string  $orig_data = addslashes($data);}//create the thumbnail:$orig = imagecreatefromstring($data);$w = imagesx($orig);$h = imagesy($orig);//calculate the width/height ratioif ($w > $h){  $ratio = $th_size / $w;  $thumb = imagecreatetruecolor($th_size, round($h * $ratio));  imagecopyresampled($thumb, $orig, 0, 0, 0, 0, $th_size, round($h * $ratio), $w, $h);}else{  $ratio = $th_size / $h;  $thumb = imagecreatetruecolor(round($w * $ratio), $th_size);  imagecopyresampled($thumb, $orig, 0, 0, 0, 0, round($w * $ratio), $th_size, $w, $h);}imagedestroy($orig);$temp_img = $temp_save . "img" . rand(10000, 99999) . rand(10000, 99999);$img_ar = getimagesize($filename);switch($img_ar[2]){  case 1: //FALL-THROUGH    //gif    //$temp_img .= ".gif";    //imagegif($thumb, $temp_img);    //break;  case 2:    //jpeg    $temp_img .= ".jpg";    $type = "jpeg";    imagejpeg($thumb, $temp_img);    break;  case 3:    //png    $temp_img .= ".png";    $type = "png";    imagepng($thumb, $temp_img);    break;  case 15:    //wbmp    $temp_img .= ".wbmp";    $type = "wbmp";    imagewbmp($thumb, $temp_img);    break;  default:    //not supported here    $errStr .= "badtype;";    break;}imagedestroy($thumb);$orig = imagecreatefromstring($data);// $width and $height are both form variables (desired width and height)if ($height == ""){  $ratio = $width / $w;  $height = $h * $ratio;}if ($width == ""){  $ratio = $height / $h;  $width = $w * $ratio;}$resized = imagecreatetruecolor($width, $height);imagecopyresampled($resized, $orig, 0, 0, 0, 0, $width, $height, $w, $h);// $temp_save is a hard-coded directory to save temporary files// create a temp filename based off random numbers:$resized_img = $temp_save . "img" . rand(10000, 99999) . rand(10000, 99999) . "_resize";switch ($type){  case 'jpeg':    $resized_img .= ".jpg";    imagejpeg($resized, $resized_img);    break;  case 'png':    $resized_img .= ".png";    imagepng($resized, $resized_img);    break;  case 'wbmp':    $resized_img .= ".wbmp";    imagewbmp($resized, $resized_img);    break;}imagedestroy($orig);

    OK, I think that's pretty much it, but I need to give you some more notes. I extracted the code out of one large file, I can send you the whole file if necessary, it includes a lot more code.Some variables are pre-defined, look at the comments in the code for descriptions of them (i.e. $temp_save, $width, height, etc).Those last few functions (imagejpg, imagepng, imagewbmp etc) can either output to the browser or to a file. I have those outputting to a random filename in the $temp_save folder.You can go to php.net and type in any function name I used above (like 'imagecopyresampled') into the Search box, search the function list, and you can get documentation on that specific function.Also, like I said before, this code is a little different because it saves to a database instead of files, so if you have any questions about it let me know.-Steve

  2. You don't want to access it with FTP, that will cause your browser to attempt to download the page (instead of displaying it), and you probably don't even want to use your browser's FTP client anyway.You need to refer to it via http. When you reference something with the file protocol (file://), the browser assumes that is a local path. You can write file://c:/test.txt to open c:/test.txt with the browser. So if you write a path with file://, then everyone better have access to the exact same path (no mapped network drives) as you do, or else their browser won't find the file.You need to put the document on a webserver, and make it accessible across the network and then refer to it with http.

  3. As far as I know, no, PHP doesn't interface with the peripherals like that. You can use javascript to display a print dialog box, but that's about it. There is a program called PHP-GTK that you can use to write Windows apps with PHP, but it's not very mature, or at least it wasn't when I was looking at it. It doesn't produce a standalone application, it still depends on a PHP install being present. And even so, I still don't think you can interface with the peripherals.

    Format

    OK, like I said, I'm not that great with .NET but I'll see what I can do.First, you need to import the VB namespace, so add this to the top of your page:

    <% @Import Namespace="Microsoft.VisualBasic" %>

    Then when you have your date here:

    <%# DataBinder.Eval(Container.DataItem,"fnl_datectd")%>

    I'm not quite sure how to format the code, but I think it should be something like this:

    <%# String.Format("{0:d}", DataBinder.Eval(Container.DataItem,"fnl_datectd"))%>

    Again, I'm totally clueless if that is even correct syntax. Here is a page for reference:http://www.aspfaqs.com/ASPScripts/PrintFAQ.asp?FAQID=181

  4. If you don't have physical access to the email server, then you probably can't change the headers it sends out. I meant to say copy and paste the headers into the forum. You can remove any domains or email addresses, I just want to see what the headers are that the mail server is attaching.

  5. You have clearly jumped on the MS haters bandwagon.
    I don't know where you got that from. Every computer I use runs Windows, I tried installing Debian on a really old set of hardware without a bootable CD-ROM drive and that basically spoiled my experience with Linux. Linux has major usability problems, once the community gets over itself and makes Linux accessible to people who don't want to spend days reading technical documentation or compiling their own drivers, then maybe I'll give it another look, but there's nothing driving me that direction. Macs seem to emphasize cuteness over everything else, something just turns me off about Macs. No offense to any Mac fanboys out there, I just don't really like using them.What I do hate about Microsoft is their project management. Vista hasn't even come out yet and it's already a failure, it's not going to live up to any of the hype that MS PR was spouting years ago. IE is just a dismal failure, it solidifed the MS monopoly, which is what they wanted it for (it succeeded there), but then they just decided to stop all development of it. And then they decided to pick it back up again. And they refuse to break backward compatibility on it. Usually I'm all for backward compatibility, but when the old version is already broken it doesn't make a lot of sense to make sure the new version is compatible with all the same bugs (or 'quirks', as the IE folk say). I'm just not holding out high hope for the Trident engine, full CSS2 support would be great, but I'll be impressed if they manage to support 60% of CSS2. They already stated that IE7 would not pass Acid2, and they stated that they are working on bugfixes first, and then making a list of the things people wants most from CSS second. They aren't on a rampage to make it all compliant, they are just starting to hear the screams of all the web developers out there and are taking notice. They can see a time when IE is not the major browser, so that's what kicked them in the pants and made them restart development on it. They aren't trying to make IE7 compliant, they are trying to stop the slide of IE marketshare. A new version every 6 years isn't really a great way to approach that, that is where Opera and Firefox destroy IE. Opera has a bittorrent client, an email client, an IRC client, and the IE team is trying to fix 6 year old bugs. I would like nothing better than to see IE go down in a ball of flame, it's the worst thing that's happened to web developers. Of course, one could also argue it's the best thing that's happened, but that's neither here nor there..
  6. You can't. ASP.NET is a lot newer than ASP classic, and it uses a completely different execution model (common language runtime, the framework, etc). You can include older classic ASP files in your newer ASP.NET projects, but you can't use the new stuff in the old stuff.

  7. It looks like the PHP installation you are running that on does have support for GD (the image library). If you are running that on your home computer, you probably used the Windows installer to set up PHP, and the installer doesn't include GD. If you want support for GD you will want to download and install the PHP zip package instead.

    what is UNIX?how to config it?
    Wow. UNIX is an operating system originally developed at Bell Labs in the 60s. One of the guys who created the C programming language also developed UNIX. Linux is one of the OS derivatives that was based off UNIX. Several people sell various implementations of UNIX, including HP (HP-UX), IBM (AIX), Sun (Solaris), and SCO (UnixWare). BSD is also based off UNIX. UNIX is not free, you have to pay for it.I'm not sure why you're asking how to configure it, UNIX configuration is not a trivial job. There are college classes on how to administer UNIX.http://en.wikipedia.org/wiki/Unix

    Format

    Heh, don't cry, it's ok. A lot of web programmers have an unusual, almost unsettling, fascination with VB.When I get back to my book tomorrow I'll see what I can do.

  8. If you are updating some element's style, like this:el.style = "xxx";Then the answer is no, all of the other styles will still be the same. In fact, I don't even know if it's possible to flat-out remove the current style sheet, but I know you can add another one through javascript. I'm sure you can probably delete the specific stylesheet object from the DOM if that's what you want to do, but you would probably have to know the address of it or something like that in order to look it up.

  9. That's a good question, I haven't heard about that.Based on the sourcecode diff for wordpress, I think it has something to do with this:http://tinymce.moxiecode.com/Which appears to be some sort of javascript content editor. It looks like the program automatically changes the rendered html, so you don't need to include them in anything. In fact, I would treat them like any other content editor (FrontPage, Dreamweaver, etc) and delete them where I see them.

    Log in

    I really need to buy someone a drink now.
    I'll take a Hangar One on the rocks, please.I'm betting your problem is how you are setting the cookie. I ran into this with my own apps, and the symptoms sound similar.First, a little primer on cookies. I'm sure you know that a cookie is a little text chunk hanging out on your local computer, and they contain information that basically the site tells the browser to save, whatever information that is. Could be a user id, a shopping cart, whatever.The way that happens, is that the server includes a header when it sends the response to the browser. The header tells the browser everything it needs to know about the cookie, the name of it, the value, expiration, all that junk. So since the cookie is essentially a header attached to some other page, you can't set a cookie and retrieve it on the same page. By the time the browser has created the cookie, the server is already done executing the code. That is the reason when you log in or log out on a lot of places, you go to some page that says "thank you, we are redirecting you". That page you see is the page that actually sets (or deletes) the cookie, and by the time you get redirected, the cookie has already been created or deleted, and the page you get redirected to now has access to the updated info.The second thing this means (that the cookie is a header) is that you actually need some page content to set the cookie. You can't juse call the setcookie() function at the end of a page and have a cookie created (actually, it produces an error if you do that anyway). You have to make the call to setcookie before any other page output, since the cookie is a header, and whenever you start output on the PHP script all the headers get sent first.So, in conclusion, consider inserting a middle page between login (or logout) and index that is totally responsible for cookie manipulation, creating and deleting. You can use the same login code you already use, the difference is that a cookie is also set. Once you actually spit output out from that page, and get the cookie set, you can redirect them to the appropriate page and have access to the cookie.I can't tell you how long it took me to figure that out.btw: the code actually looks pretty decent, you got stats and everything going on. you go!
  10. I'm not calling everyone ignorant, I'm calling the one guy who made assumptions about my qualifications arrogant.Hey man, I'm not complaining, I'm defending my position, which is that tables and CSS both deserve to be used. Neither is an all-encompassing standard. CSS began as a "style" specification, for easy manipulation of colors, fonts, etc, and all of sudden it is the medium of choice for structure? That's fine, but I'm going to wait until there is across-the-board support in my client base before I start requiring my users to use a browser that supports the latest spec. I can't tell some CEO that however many thousand employees he has need to upgrade their software because of reasons he will never understand. That's just not what I want to do with my time.The fact is that browsers are behind the times, and that's the way things go. Browser vendors are scrambling to implement CSS2 or CSS2.1 (IE7 will have full support for CSS2? Really? And Vista will have a revolutionary new file structure too, right?) while the W3C is soliciting input on CSS3. I don't expect the vendors and the W3C to hold eachother's hands and produce everything at the same time, but just the same, web developers can't be expected to jump on every bandwagon as soon as the W3C says jump, because the fact is that the browsers that people are using are so much older than the current specs, that it doesn't really matter if we follow the current spec or the last spec.And yes, my posts get a little agressive sometimes, but only when someone starts personally insulting me. Excuse me, but I have a problem with that.

  11. Well, I don't think that's deprecated, in fact I think that should work. But I've never used rgb myself, I always use hex, which is widely supported. 192 in hex is C0, so you can write the same thing like this:<span style="color: #C0C0C0;"></span>If you need to convert from decimal to hex, you can either fire up your chosen image editing program like Paint Shop Pro or Photoshop and do it there, or you can open the Windows calculator, select scientific mode (View -> Scientific), make sure the "Dec" radio button is checked, type in your number, and hit the "Hex" radio button to convert.

  12. err.. I'm not really sure what you're asking. DOM is the Document Object Model, and each browser implements it's own version of the DOM. You can access various elements in the page through javascript via the DOM, that's what it's there for.So I'm not really sure what you're asking. The only time you really "use" the DOM is when you are writing javascript code to access various things on the page. The browser, in turn, uses the DOM when it is rendering the page.You can use the DOM Link object to access or change which stylesheets are applied to the page, or you can use the DOM Style object to change the styles that are applied to each element. You do all of these things through javascript.If that answers your question, cool, if not, be a little more specific with what you are trying to do.

    Format

    Ahh.. you're working in ASP.NET. Which means you probably are not using JScript, and hopefully not VB.NET (if you are, you have my sympathy).Look on the top of the page, and look for this:<%@ Page Language="xxx" %>Tell me what the 'xxx' part is on your page.There are several built-in converters in .NET, but I'm not much of a .NET pro. But I've got a book sitting next to me, so if I can help you I will.

    Format

    When you use ASP, you either write your code in JScript or VBScript. If you chose JScript, you can use those links (JScript is essentially the same as JavaScript, only Microsoft developed it). If you chose VBScript, then I can't really help you. If you don't know what you are working in, paste some code and I'll tell you. You might also be able to see something at the top that says one of these:<% @LANGUAGE="JScript" %>or <% @LANGUAGE="VBScript" %>That will also tell you what you're working with.

  13. You probably don't have that many. There are probably a few errors up top that are causing other things to get flagged, but just start at the top of the list and work your way down. Most things should be pretty easy to fix (i.e. replace an attribute with some CSS or something).

×
×
  • Create New...