Ajax Upload and Resize an Image with PHP

Hi Guys,
Today I am presenting the most important social networking feature called ajax upload and resize an image without refreshing the page using PHP and jquery.

demo




This article contains three folders called js,includes and uploads with PHP files.

  • includes
    — getExtension.php
    — compressImage.php
  • js
    — jquery.min.js
    — jquery.form.js
  • uploads
    index.php
    ajaximageupload.php




We can upload the image through PHP page. And resize the uploaded image using Ajax in php page.

Javascript Code







index.php

Contains simple PHP and HTML code. Here $session_id=1 means user id session value.




 

Upload image:

 

 

ajaximage.php

Contains PHP code. This script helps you to upload images into uploads folder. Image file name rename into timestamp+session_id.extention

";
}

//Original Image
if(move_uploaded_file($uploadedfile, $path.$actual_image_name))
{
//Insert upload image files names into user_uploads table
mysqli_query($db,"UPDATE users SET profile_image='$actual_image_name' WHERE uid='$session_id';");
echo "";
}
else
echo "failed";
}
else
echo "Image file size max 1 MB"; 
}
else
echo "Invalid file format.."; 
}
else
echo "Please select image..!";
exit;
}
?>

compressImage.php

Re-sizing image into different pixel dimensions.


getExtension.php

This extracts file extension.

function getExtension($str)
{
$i = strrpos($str,".");
if (!$i)
{
return "";
}
$l = strlen($str) - $i;
$ext = substr($str,$i+1,$l);
return $ext;
}

download

If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.

One thought on “Ajax Upload and Resize an Image with PHP

  1. where Can you buy legal steroids

    Dr. O’Connor has over 20 years of experience treating women and men with a historical past of anabolic
    steroid, SARM, and PED use. He has been a board-certified MD since 2005 and
    supplies guidance on harm discount methodologies. This is why sure
    sporting federations are looking to ban athletes if they have ever taken steroids during their lifetime, as
    it has a long-term or permanent impact. In our experience, the least poisonous stack for mass could be testosterone
    and Deca Durabolin. It is essential for readers to understand
    that stacks will enhance the severity of side effects.
    Endogenous shutdown can be severe on trenbolone, and thus users
    will need to wait a quantity of months earlier than their testosterone ranges recover
    earlier than using additional cycles.
    Personally, I have not seen any fat loss on creatine,
    though I often use it when bulking and thus consuming extra calories.
    The research regarding omega-3 fatty acid’s have an effect on on muscle growth is minimal,
    but fascinating. One systematic evaluation discovered it might amp up muscle mass and strength, especially in people in danger for muscle loss (sarcopenia) as
    a outcome of things like persistent ailments or fatigue.

    However, they should solely be used sparingly, due to your physique
    increase a tolerance to them over time. Over the long term, this may end
    up in torpid workouts and becoming depending on robust stimulants to get you thru your workout (31).
    Human growth hormone (HGH) is often taken in exogenous kind by bodybuilders trying
    to add muscle and burn fat. Some of the most muscular bodybuilders on the planet are born with myostatin deficiencies,
    explaining their freakish size. Creatine is undoubtedly probably the greatest natural bodybuilding dietary supplements around.
    ZMA is a patented method that mixes zinc, magnesium, and vitamin B6 together.

    Some research reveals ZMA can significantly increase testosterone and development hormone ranges.

    Please inform your doctor in case you are taking any of these type of
    medicines. Get helpful tips and steerage for every thing from combating inflammation to discovering the
    most effective diets for weight loss…from workout routines to build a stronger core
    to recommendation on treating cataracts. PLUS,
    the newest information on medical advances and breakthroughs
    from Harvard Medical School consultants. Research have proven that supplementing your creatinine
    intake can result in a rise in fat-free physique mass.

    The physique consequently retains a lot more water, a few of which shifts contained in the muscles as intracellular fluid.
    ATP, an power molecule, manufacturing also will increase, inflicting
    increased muscular energy and endurance. In pure bodybuilders,
    creatine has been shown to double energy and muscle features when compared to coaching alone (16).
    Some believe it actually works very well for growing testosterone and have
    experienced obvious muscle features (including myself).

    A exercise that is extra athletic will result in larger muscle
    gain, which will help you burn additional fat. The odds
    of damage occurring on Superdrol are high in comparison to other anabolic-androgenic steroids (AAS), because of energy levels usually increasing drastically in a brief area of time.
    Thus, bodybuilders must be cautious regarding lifting as heavy as possible on Superdrol, with a couple of of our
    sufferers experiencing ruptured hernias and requiring emergency medical surgical procedure.
    To construct a major quantity of muscle, you
    must be in a calorie surplus and be consuming enough protein. Protein ought
    to be distributed as evenly as you’ll have the ability to throughout the day, and carbs should
    be consumed predominately preworkout and before bed.
    The best legal steroids, like any dietary supplement, can have unwanted effects, but
    they are largely delicate. Many of these compounds exist already
    in your body, so side-effects are sometimes the outcomes of
    your physique getting used to the next dose.
    When you’re taking NSAIDS, it is extremely essential that your medical doctors know if you are taking another drugs.
    This includes prescription and non-prescription medicines in addition to
    contraception tablets, nutritional vitamins, and natural dietary supplements.
    Aromatase inhibitors are a category of medicines that work by blocking the enzyme aromatase, the enzyme that converts androgens into estrogen. Aromatase inhibitors
    are used within the treatment of breast most cancers to cut back ranges of circulating estrogen.
    When utilizing as therapy for arthritis symptoms, these
    medicines ought to be taken often in order to be
    best. When first starting on NSAIDS, it might take 2 weeks or more to get the maximum profit.
    Please inform you physician if you are to have any kind of surgical procedure, including dental work.
    How you eat and practice will decide how a lot muscle
    you construct and how a lot fat you lose.
    Creatine is an especially researched supplement and
    has been proven in analysis to extend athletic efficiency.

    You will reap the advantages of extra muscle by with the power to do extra reps in your
    exercise and dealing tougher. Clients find that the ache reduction gel works nicely, with one buyer particularly noting its effectiveness on knees
    and another mentioning its benefits for various physique components.

    While omega-3s have potential power perks, we’re still ready
    for the massive studies to substantiate the hype.
    “Those are your two massive ones. After that there may be some small benefits from fish oil (which is a brilliant common health supplement anyway) and beta-alanine.” Despite the analysis, the primary journey to
    the joint pain specialist is normally a recommendation to cortisone.
    Right Now, despite the hazards, cortisone use stays widespread as a normal of care.

    Read vendor evaluations and find licensed distributors to ensure your safety as a buyer.

    Before taking any kind of supplement, make positive that you discuss it
    with your physician or nutritionist. Should you feel any unwell
    impact from taking a complement, don’t assume twice about getting medical assistance.
    Being alive and healthy is so much extra necessary than being buffed like a beast.

    Every ingredient has its own set of benefits and possible unwanted aspect effects, so knowing them offers you an idea
    of how the product can doubtlessly work. Barlowe’s Suma Root Extract where Can you buy legal steroids be utilized as a tonic for constructing lean muscle and growing endurance.
    It’s suitable for vegans and for these with allergy symptoms to wheat and corn (it doesn’t comprise fillers of any sort).

Leave a Reply

Your email address will not be published.