GB_001 Posted September 3, 2009 Share Posted September 3, 2009 hi, For some reason my upload script stopped working and I don't know why. Do any of you see a problem? <?php include('Connect.php'); session_start(); $path = "/home/gb/public_html/Images/"; $MN=$_SESSION['email']; $result = mysql_query("SELECT * FROM Ysers WHERE email='$MN'"); $row= mysql_fetch_array( $result ); $imgName = $_FILES['userfile']['name']; $max_size = 250000; if (!isset($_FILES['userfile'])) exit; if (is_uploaded_file($_FILES['userfile']['tmp_name'])) { if ($_FILES['userfile']['size']>$max_size) { echo "<font color=white> Error: File size is over 400kb.<br>"; exit; } if (($_FILES['userfile']['type']=="image/gif") || ($_FILES['userfile']['type']=="image/pjpeg") || ($_FILES['userfile']['type']=="image/jpeg") || ($_FILES['userfile']['type']=="image/png")) { $ext = strrchr($imgName, "."); $Newname = md5(rand() * time()) . $ext; $res = copy($_FILES['userfile']['tmp_name'], $path . $_FILES['userfile']['name']. $Newname); $MM = $_FILES['userfile']['name']. $Newname; if (!$res) { echo "<font color=white><b>Upload failed!<br/>"; exit; } else { echo "<font color=white><b>Upload successful<br/>"; } $picd=$row['Picture']; if($picd!="Default.jpg") { $unlinkg= "/home/gb/public_html/Images/$picd"; unlink($unlinkg); } } else { echo "<font color=white><b>Error: Wrong file type."; exit; } } $my_file = $_FILES['userfile']['name']; $query="UPDATE Ysers SET Picture='$MM' WHERE email='$MN' LIMIT 1"; mysql_query($query) or die(mysql_error()); mysql_close(); ?> <body bgcolor='black' onLoad='parent.Profile(); parent.PicRenew();'></body> Thankyou, GB. Link to comment https://forums.phpfreaks.com/topic/172928-upload-script-stopped-working/ Share on other sites More sharing options...
play_ Posted September 3, 2009 Share Posted September 3, 2009 does it give errors? try checking if the directory is writable Link to comment https://forums.phpfreaks.com/topic/172928-upload-script-stopped-working/#findComment-911427 Share on other sites More sharing options...
GB_001 Posted September 3, 2009 Author Share Posted September 3, 2009 No, it doesn't give any errors and the script worked before. But for some reason it stopped. Link to comment https://forums.phpfreaks.com/topic/172928-upload-script-stopped-working/#findComment-911636 Share on other sites More sharing options...
PFMaBiSmAd Posted September 3, 2009 Share Posted September 3, 2009 A) You have not bothered to state what is not working. The upload? The database query? What do you actually see in front of you when you try it? B) Add the following immediately after the first opening <?php tag to see what exactly your form processing code is receiving and if there are any php errors - ini_set("display_startup_errors", "1"); ini_set("display_errors", "1"); error_reporting(E_ALL); echo "<pre>"; echo "POST:"; print_r($_POST); echo "FILES:"; print_r($_FILES); echo "</pre>"; Link to comment https://forums.phpfreaks.com/topic/172928-upload-script-stopped-working/#findComment-911643 Share on other sites More sharing options...
GB_001 Posted September 3, 2009 Author Share Posted September 3, 2009 The upload itself isn't working, everything else it. II am also not getting any errors. EDIT: It echoed POST:Array. Link to comment https://forums.phpfreaks.com/topic/172928-upload-script-stopped-working/#findComment-911742 Share on other sites More sharing options...
GB_001 Posted September 3, 2009 Author Share Posted September 3, 2009 And FILES: Array. Link to comment https://forums.phpfreaks.com/topic/172928-upload-script-stopped-working/#findComment-911766 Share on other sites More sharing options...
PFMaBiSmAd Posted September 3, 2009 Share Posted September 3, 2009 If both the $_POST and $_FILES arrays are empty (assuming the form you are using now is one that you were using when it worked), it is most likely that you are exceeding the post_max_size setting - post_max_size integer Sets max size of post data allowed. This setting also affects file upload. To upload large files, this value must be larger than upload_max_filesize. If memory limit is enabled by your configure script, memory_limit also affects file uploading. Generally speaking, memory_limit should be larger than post_max_size . When an integer is used, the value is measured in bytes. Shorthand notation, as described in this FAQ, may also be used. If the size of post data is greater than post_max_size, the $_POST and $_FILES superglobals are empty. This can be tracked in various ways, e.g. by passing the $_GET variable to the script processing the data, i.e. <form action="edit.php?processed=1">, and then checking if $_GET['processed'] is set. Link to comment https://forums.phpfreaks.com/topic/172928-upload-script-stopped-working/#findComment-911828 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.