Or1g1naL
-
Posts
13 -
Joined
-
Last visited
Never
Posts posted by Or1g1naL
-
-
I thought mime_content_type() had been deprecated.
I'm just if you think this method of uploading images is secure for public use.
-
what manual?
-
ym_chaitu - I now understand what you're talking about. Does this look better?
if($type = "image"){ $image_path = $image_directory.$_FILES['ufile']['name'][0]; copy($_FILES['ufile']['tmp_name'][0], $image1_path); }
It would be secure enough right?
-
$type = explode("/".$_FILES['ufile']['type'][0]); if($typep[0] == "image"){ $image_path = $image_directory.$_FILES['ufile']['name'][0]; copy($_FILES['ufile']['tmp_name'][0], $image1_path); }
Then is this secure?
-
Yes. It is redundant in security.
What do you mean?
-
$ext = basename(strtolower($_FILES['ufile']['type'][0]; // "jpg" if($ext == "x-png" or $ext == "pjpeg" or $ext == "gif"){ $image_path = $image_directory.$_FILES['ufile']['name'][0]; copy($_FILES['ufile']['tmp_name'][0], $image1_path); }
Is this a bad idea for public use?
-
Thank you.
-
function updateNode($node, $nodeID, $childNode, $cnodeValue, $xmlFile){ $dom = new DOMDocument(); $dom->load($xmlFile); $node = $dom->getElementsByTagName($node); foreach($node as $nodes){ if($nodes->getAttribute('id') == $nodeID){ $nodes->getElementsByTagName($childNode)->item(0)->nodeValue = $cnodeValue; } } $dom->save($xmlFile); } if($_POST['update'] == 'Update'){ updateNode("listing", $_POST['id'], "price", $_POST['price'], $xmlfile); updateNode("listing", $_POST['id'], "beds", $_POST['beds'], $xmlfile); updateNode("listing", $_POST['id'], "baths", $_POST['baths'], $xmlfile); updateNode("listing", $_POST['id'], "sqft", $_POST['sqft'], $xmlfile); updateNode("listing", $_POST['id'], "year", $_POST['year'], $xmlfile); updateNode("listing", $_POST['id'], "street", $_POST['street'], $xmlfile); updateNode("listing", $_POST['id'], "city", $_POST['city'], $xmlfile); updateNode("listing", $_POST['id'], "state", $_POST['state'], $xmlfile); updateNode("listing", $_POST['id'], "zip", $_POST['zip'], $xmlfile); }
This is all my handy work and wonder what other more experienced people would do instead.
-
Could you explain that a little better?
I'm sure you know that
$image 'code to fetch image from tht site';
should be...
$image = 'code to fetch image from tht site';
right?
-
and FWIW
Unix timestamps represent the number of seconds since one millisecond before midnight Jan. 1 (i.e. Dec 31, 1969 11:59:59.999)
-
function updateNode($node, $nodeID, $childNode, $cnodeValue, $xmlFile){ $dom = new DOMDocument(); $dom->load($xmlFile); $node = $dom->getElementsByTagName($node); foreach($node as $nodes){ if($nodes->getAttribute('id') == $nodeID){ $nodes->getElementsByTagName($childNode)->item(0)->nodeValue = $cnodeValue; } } $dom->save($xmlFile); } updateNode("contact", "4bafdebc54aac", "firstname", "Peter", "temp.xml");
And it works!
Looks like it was my own confidence in my self that was holding me back. I was sure I was creating the function wrong.
Thanks guys
-
and my first post! I have lurked phpfreaks forum many times and copy little bits of code. The information on this site is a lot of help and the people here are great. Lately my code is looking messy because I dont' know how to create my own functions! :'(
Here is the code I want to turn into a function. All this does is update a value in a xml file with the the attribute id 4bafdebc54aac.
$contact_id = "4bafdebc54aac"; $xmlfile = "temp.xml"; $dom = new DOMDocument(); $dom->load($xmlfile); $contacts = $dom->getElementsByTagName("contact"); foreach($contacts as $contact){ if($contact->getAttribute('id') == $contact_id){ $contact->getElementsByTagName('firstname')->item(0)->nodeValue = "Jim"; } } $dom->save($xmlfile);
This is my attempt to create a function from that, but it isn't working. The code above this works perfectly but I can't put it into a function.
function updateNode($node, $nodeID, $childNode, $cnodeValue, $xmlFile){ $doc = new DOMDocument(); $doc->load($xmlFile); $node = $dom->getElementsByTagName($node); foreach($node as $nodes){ if($nodes->getAttribute('id') == $nodeID){ $nodes->getElementsByTagName($childNode)->item(0)->nodeValue = $cnodeValue; } } } updateNode("contact", "4bafdebc54aac", "firstname", "Peter", "temp.xml");
Everything looks ok to me but it does not work. Could anybody give me any tips? I would really be greatful.
POST method upload secure?
in PHP Coding Help
Posted
I already knew it was deprecated. Everybody knows that. jeez
I'm just asking if uploading an image using a form is secure in your opinion.
I don't want it to upload if it isn't an image file.