Jump to content
PAProject

Upload image size error?

Recommended Posts

Ma scuzati de dublu post dar nu pot edita.

Uitati si tot scriptul.

 

<?php
include_once 'includes.php';
include_once 'public.php';
include_once 'includes/getExtension.php';
$valid_formats = array("jpg", "png", "gif", "bmp","jpeg","PNG","JPG","JPEG","GIF","BMP");
if(isset($_POST) && $_SERVER['REQUEST_METHOD'] == "POST") {
      $name = $_FILES['photoimg']['name'];
      $size = $_FILES['photoimg']['size'];
      $imageType=$_POST['imageType'];
      if(strlen($name)) {
      $ext = getExtension($name);
      if(in_array($ext,$valid_formats)) {
      if($size<(1024*$uploadImageSize)) { // Check the image size 
      $actual_image_name = $uid.time().".".$ext; // Change the image ame
      $tmp = $_FILES['photoimg']['tmp_name'];
      include 'includes/compressProfileImage.php';
      $style='';
      $class='';
      $bgSave='';
      if($imageType == 1) {
      /* User Profile Pic */
      $widthArray = array($TimelineProfilePX); /* Image Pixel Size*/
      $prefix='user'; /* Image Prefix */
      foreach($widthArray as $newwidth) {
        // Compres the image using compressProfileImage.php in includes file
        $filename=compressProfileImage($ext,$tmp,$profile_image_path,$actual_image_name,$newwidth,$prefix);
        }
        // Then prefix the image like user_134567.jpg
        $final_image_name=$prefix.'_'.$actual_image_name;
        // Upload an image 
        $newdata=$Mat->Profile_Image_Upload($uid,$final_image_name);
        $style='timelineIMG';
        }
        if($newdata) {
          echo $bgSave.'<img src="'.$base_url.$filename.'"  id="'.$style.'" class="'.$class.'"/>';
        } else {
        echo "Fail upload folder with read access.";
        }
        } else {
            echo "Image file size max 1 MB";
        }
        } else {
        echo "Invalid file format.";}
        } else
            echo "Please select image..!";
          exit;
    }
    
    
?>

 

Share this post


Link to post
Share on other sites

Cat ocupa imaginea mai exact?


PHP Developer - Not available for freelancing right now

Daca ai de gand sa postezi la categoria IPB, nu uita sa citesti regulamentul: Link regulament

Share this post


Link to post
Share on other sites

Adauga inainte de ace-l if un:

echo $uploadImageSize . "<br />" . $size;

Si vezi ce marimi iti da.


PHP Developer - Not available for freelancing right now

Daca ai de gand sa postezi la categoria IPB, nu uita sa citesti regulamentul: Link regulament

Share this post


Link to post
Share on other sites

Eu ma refer sa vezi ce marimi iti returneaza echoul ala.

Poate marimea care iti da nu e un numar, poate da eroare altundeva.

Trebuie sa faci un debug la codu acela si sa vezi ce returneaza fiecare variabila inainte de ifu ala.


PHP Developer - Not available for freelancing right now

Daca ai de gand sa postezi la categoria IPB, nu uita sa citesti regulamentul: Link regulament

Share this post


Link to post
Share on other sites

Pai si unde ar trebui sa.mi returneze marimile? Am pus codul si imi da eroare ca nu e dfininit l.am definit si imi da tot ce imi dadea la inceput...

si cum adica sa fac un debug ca nu pricep ? 

Edited by PAProject

Share this post


Link to post
Share on other sites

Pai codu:

$name = $_FILES['photoimg']['name'];
$size = $_FILES['photoimg']['size'];

Ar trebui sa citeasca de la "formu" de upload odata ce-i dai submit la formular.

Despre debug, ar trebui sa sti daca lucrezi cu PHP sau cu orice limbaj de programare, in cazu lu PHP vezi aici: http://php.net/manual/en/debugger.php


PHP Developer - Not available for freelancing right now

Daca ai de gand sa postezi la categoria IPB, nu uita sa citesti regulamentul: Link regulament

Share this post


Link to post
Share on other sites

Am facut cum mi-ai zis dar nu imi apare nimic !

Nu pot rezolva ma chinui de trei zile ... ma dau batut ...problema e ca nu are nimic din cod-ul de mai sus din alta parte dar nu mai stiu unde am umblat ...

Edited by PAProject

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...