본문 바로가기

반응형

웹프로그래밍

(125)
Conditional comments with IE Conditional comments with IE Since Internet Explorer 5, conditional comments have been used to show or hide extra content from Internet Explorer. The syntax The example below will add a CSS style sheet only if the browser viewing the page is IE6: Any HTML that appears between the IF statement will be added to the document if viewed using the specified version of Internet Explorer. You can use th..
[php] 파일 이동, 복사 함수 php에서는 copy함수를 이용하여 간단하게 파일을 복사하거나 unlink(또는 delete)함수로 파일을 삭제할 수 있습니다. 이 두 함수는 복사, 삭제에 성공할 경우 true를, 실패하면 오류 코드 메시지를 표시하므로 함수 앞에 @를 붙여 보안 유효성을 높여 주도록 합니다. bool copy ( string $source , string $dest [, resource $context ] ) (PHP 4, PHP 5) copy(원본 파일명, 복사 파일명); unlink(삭제 파일명); 대상 파일이 이미 존재하면 덮어 쓰는 점에 주의가 필요합니다. 다음은 파일 복사 예제입니다. 예제 (ex #1 다음은 파일 이동 예제입니다. 예제 (ex #2 단순히 파일이름만 변경 원할 경우 rename함수를 이용하면..
PHP + jQuery AJAX Upload 1. input file tag on event $('#tmp_widget_file').on('change', prepareUpload); function prepareUpload(event){files = event.target.files} $('#twf').on('submit', uploadFiles); 2. uploadFiles function function uploadFiles(event){ event.stopPropagation(); event.preventDefault(); var data = new FormData(); $.each(files, function(key, value){ data.append(key, value); }); $.ajax({ url: './page/getWidget..
PHP XML CDATA Parsing define(INFO, $path."info.xml"); $infoXML = new DOMDocument(); $infoXML->load(INFO); $category = getXMLTextContent($infoXML, "group"); function getXMLTextContent($xml, $field){ $vars = $xml->getElementsByTagName($field); foreach($vars as $var){ foreach($var->childNodes as $child) { if ($child->nodeType == XML_CDATA_SECTION_NODE) { return $child->textContent; } } } }
PHP DOMDocument getting Attribute of Tag $xmldoc = new DOMDocument(); $xmldoc->load('api response address'); foreach ($xmldoc->getElementsByTagName('item') as $feeditem) { $nodes = $feeditem->getElementsByTagName('file'); $linkthumb = $nodes->item(0)->getAttribute('data'); echo $linkthumb; }
임시로 PHP오류 출력할 때 일부 호스팅 환경에서는 PHP오류발생시 500에러코드로 분류되며 흰 공백화면으로 띄며 모든 작업이 중단되는 경우가 있다. 이럴 때 php 오류가 어느 라인에서 발생했는지 알수없어 답답하다. 그럴떄 아래와 같은 방법을 쓰면 된다. error_reporting(E_ALL); ini_set("display_errors", 1);
Javascript 오른쪽 마우스 버튼 막기 function detectLeftButton(evt){ evt = evt || window.event;var button = evt.which || evt.button;return button == 1; }
Javascript 페이지에서 가장 큰 z-index 구하기 function maxZ(){ return Math.max.apply(null,$.map($('body > *'), function(e,n){if($(e).css('position')=='absolute')return parseInt($(e).css('z-index'))||1;})); }

반응형