Resize image php upload11/19/2023 ![]() In this variable $resizeObj = new resize('sample.png') you need to link your uploaded picture url Check read/write permissions on the directory" Make sure you chmod the directory to be writeable A common cause of file moving failures is because of bad permissions on the directory attempting to be written to $q = $conn->prepare($sql2) or die("failed!") $sql2 = "UPDATE people SET surname = (SELECT surname FROM user WHERE username=:user_id1) WHERE username=:user_id2" $q = $conn->prepare($sql1) or die("failed!") $sql1 = "UPDATE people SET firstname = (SELECT firstname FROM user WHERE username=:user_id1) WHERE username=:user_id2" $q->bindParam(':conditional', $conditional, PDO::PARAM_STR) $q->bindParam(':imagename', $imagename, PDO::PARAM_STR) $q->bindParam(':lname', $lname, PDO::PARAM_STR) $q->bindParam(':fname', $fname, PDO::PARAM_STR) $q->bindParam(':user_id', $user_id, PDO::PARAM_STR) $q->bindParam(':category', $category, PDO::PARAM_STR) $q->bindParam(':contact', $contact, PDO::PARAM_STR) $q->bindParam(':price', $price, PDO::PARAM_STR) $q = $conn->prepare($sql) or die("failed!") $sql = "insert into people (price, contact, category, username, fname, lname, expire, filename, conditional, posttime) values (:price, :contact, :category, :user_id, :fname, :lname, now() + INTERVAL 1 MONTH, :imagename, :conditional, now())" We are *not* putting the image into the database we are putting a reference to the file's location on the server NOTE: This is where a lot of people make mistakes. If (move_uploaded_file($image, $TARGET_PATH)) Lets attempt to move the file from its temporary directory to its new home $_SESSION = "A file with that name already exists" You could get past filename problems by appending a timestamp to the filename and then continuing Here we check to see if a file with that name already exists $_SESSION = "You must upload a jpeg, gif, or bmp" You check the file type instead of the extension because the extension can easily be faked Check to make sure that our file is actually an image Make sure all the fields from the form have inputs ![]() $TARGET_PATH = "img/users/$category/$user_id/" Note that there is a trailing forward slash This variable is the path to the image folder where all the images are going to be stored ![]() Grab the User ID we sent from our form How would i resize the image before or during the upload?
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |