Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

374
Views
¿Cómo obtener el tamaño de la imagen (alto y ancho) y verificar la imagen usando JavaScript en IE?

¿Hay alguna API o método de JavaScript o jQuery para obtener las dimensiones de una imagen en la página?

ingrese la descripción de la imagen aquí

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Esta es la solución:

 $("#file").change(function (event) { var file = this.files[0]; if (file) { var imagefile = file.type; var match = ["image/jpeg", "image/png", "image/jpg", "image/tiff"]; if (!((imagefile == match[0]) || (imagefile == match[1]) || (imagefile == match[2]))) { $('#portal_introduce_file').val(""); this.files = null; alert("有効な画像ファイルを選択してください。\n注:許可される画像タイプは jpeg、png、jpg、tiff、pngのみです。") return false; } else { // 画像の寸法を取得するヘルパーimg = new Image(); img.src = URL.createObjectURL(file); // 次のハンドラーは、画像が正常に読み込まれた後に起動しますimg.onload = function () { debugger if (img.width <= 750 && img.height <= 170) { $('#portal_introduce_file').val(file.name); } else { alert('「' + img.width + 'x' + img.height + '」' + 'サイズが無効です。\n' + '画像: 750x170ビクセルで作成'); $('#portal_introduce_file').val(""); } }; img.onerror = function () { alert('画像に問題がありました。') $('#portal_introduce_file').val(""); }; } } });
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!