Jump to content

Search the Community

Showing results for tags 'wont work'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. I have a web page that lets user upload their profile photo. The PHP script works, but sometimes it just wont upload the photo. It will even give you a success message that the image was uploaded but it wont add the filename to the database nor will it save the file on the server. If you keep trying to upload the same image for couple more times then it will work and upload the photo. So i need some help in debugging it. Where am i going wrong? I am also using this thumb_function.php file which i got from internet, it basically saves thumbnails in a seperate folder, it works fine. Here is the PHP script that i am using. // Check if the button was clicked or not and process the profile updation if(isset($_POST['btnphoto'])){ include('php/thumb_function.php'); $filename = $_FILES["txtphoto"]["name"]; $newfilename = sha1($userid.$email); $extension = substr(strrchr($filename,'.'),1); $newfilename = $newfilename.".".$extension; $allowedExts = array("jpg", "jpeg", "gif", "png"); if ((($_FILES["txtphoto"]["type"] == "image/gif") || ($_FILES["txtphoto"]["type"] == "image/jpeg") || ($_FILES["txtphoto"]["type"] == "image/png")) && ($_FILES["txtphoto"]["size"] < 1048576) && in_array($extension, $allowedExts)){ if ($_FILES["txtphoto"]["error"] > 0){ $msg = "Error: " . $_FILES["file"]["error"] . "<br>"; } else { $path="../photos/".$newfilename; // the path with the file name where the file will be stored, upload is the directory name. if(move_uploaded_file ($_FILES["txtphoto"]["tmp_name"],$path)){ if ($stmt = $mysqli->prepare("UPDATE student_profile SET photo = ? WHERE user_id = ?")) { // Bind the variables to the parameter as strings. $stmt->bind_param("si", $newfilename, $userid); // Execute the statement. $stmt->execute(); // Close the prepared statement. $stmt->close(); } $msg = 'Your Photo has been updated... '; } else { $msg = 'Failed to upload file Contact Site admin to fix the problem'; exit; } $file = $newfilename; $save = $file; $t_w = 100; $t_h = 100; $o_path = "../photos/"; $s_path = "../photos/thumbnails/"; Resize_Image($save,$file,$t_w,$t_h,$s_path,$o_path); } } else { $msg = 'File is of a wrong type or too heavy.'; } } Here is the HTML form code.. <form name="frmphoto" method="post" action="" enctype="multipart/form-data"> <table border="0" cellpadding="5" cellspacing="5"> <tr><td>Upload Profile Photo : </td></tr> <tr><td><input type="file" name="txtphoto" size="45"></td></tr> <tr><td><input type="submit" name="btnphoto" value="Update Photo"></td></tr> </table> </form>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.