mbradley Posted September 30, 2009 Share Posted September 30, 2009 Ok well heres the thing i have tested Countless upload forms and even made one that i could upload ANYTHING and everything and still doing same thing... browse for file > Put file in the text box > hit upload > acts like it is uploading for a long time > then comes back to the form and with nothing uploaded and no errors at all... Hosting on godaddy and with 5.2 php on it script below that am using at this point <?php session_start(); if(!session_is_registered(myusername)){ header("location:../index.php"); } else{ $user = $_SESSION['myusername']; $rank = $_SESSION['rank']; if($rank != 1){ header("location:../index.php"); } } echo '<a href="../logout.php">LOGOUT</a><br>'; #################################################################### # File Upload Form 1.0 #################################################################### # For updates visit http://www.zubrag.com/scripts/ #################################################################### #################################################################### # SETTINGS START #################################################################### // Folder to upload files to. Must end with slash / define('DESTINATION_FOLDER','../cds/'); // Maximum allowed file size, Kb // Set to zero to allow any size define('MAX_FILE_SIZE', 65000); // Upload success URL. User will be redirected to this page after upload. define('SUCCESS_URL','http://mgmnetlan.com/ch'); // Allowed file extensions. Will only allow these extensions if not empty. // Example: $exts = array('avi','mov','doc'); $exts = array('mp3'); // rename file after upload? false - leave original, true - rename to some unique filename define('RENAME_FILE', false); // Need uploads log? Logs would be saved in the MySql database. define('DO_LOG', true); // MySql data (in case you want to save uploads log) define('DB_HOST','******'); // host, usually localhost define('DB_DATABASE','*******'); // database name define('DB_USERNAME','*******'); // username define('DB_PASSWORD','******'); // password /* NOTE: when using log, you have to create mysql table first for this script. Copy paste following into your mysql admin tool (like PhpMyAdmin) to create table If you are on cPanel, then prefix _uploads_log on line 205 with your username, so it would be like myusername_uploads_log CREATE TABLE _uploads_log ( log_id int(11) unsigned NOT NULL auto_increment, log_filename varchar(128) default '', log_size int(10) default 0, log_ip varchar(24) default '', log_date timestamp, PRIMARY KEY (log_id), KEY (log_filename) ); */ #################################################################### ### END OF SETTINGS. DO NOT CHANGE BELOW #################################################################### // Allow script to work long enough to upload big files (in seconds, 2 days by default) @set_time_limit(172800); // following may need to be uncommented in case of problems // ini_set("session.gc_maxlifetime","10800"); function showUploadForm($message='') { $max_file_size_tag = ''; if (MAX_FILE_SIZE > 0) { // convert to bytes $max_file_size_tag = "<input name='MAX_FILE_SIZE' value='".(MAX_FILE_SIZE*1024)."' type='hidden' >\n"; } // Load form template include ('file-upload.html'); } // errors list $errors = array(); $message = ''; // we should not exceed php.ini max file size $ini_maxsize = ini_get('upload_max_filesize'); if (!is_numeric($ini_maxsize)) { if (strpos($ini_maxsize, 'M') !== false) $ini_maxsize = intval($ini_maxsize)*1024*1024; elseif (strpos($ini_maxsize, 'K') !== false) $ini_maxsize = intval($ini_maxsize)*1024; elseif (strpos($ini_maxsize, 'G') !== false) $ini_maxsize = intval($ini_maxsize)*1024*1024*1024; } if ($ini_maxsize < MAX_FILE_SIZE*1024) { $errors[] = "Alert! Maximum upload file size in php.ini (upload_max_filesize) is less than script's MAX_FILE_SIZE"; } // show upload form if (!isset($_POST['submit'])) { showUploadForm(join('',$errors)); } // process file upload else { while(true) { // make sure destination folder exists if (!@file_exists(DESTINATION_FOLDER)) { $errors[] = "Destination folder does not exist or no permissions to see it."; break; } // check for upload errors $error_code = $_FILES['filename']['error']; if ($error_code != UPLOAD_ERR_OK) { switch($error_code) { case UPLOAD_ERR_INI_SIZE: // uploaded file exceeds the upload_max_filesize directive in php.ini $errors[] = "File is too big (1)."; break; case UPLOAD_ERR_FORM_SIZE: // uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form $errors[] = "File is too big (2)."; break; case UPLOAD_ERR_PARTIAL: // uploaded file was only partially uploaded. $errors[] = "Could not upload file (1)."; break; case UPLOAD_ERR_NO_FILE: // No file was uploaded $errors[] = "Could not upload file (2)."; break; case UPLOAD_ERR_NO_TMP_DIR: // Missing a temporary folder $errors[] = "Could not upload file (3)."; break; case UPLOAD_ERR_CANT_WRITE: // Failed to write file to disk $errors[] = "Could not upload file (4)."; break; case 8: // File upload stopped by extension $errors[] = "Could not upload file (5)."; break; } // switch // leave the while loop break; } // get file name (not including path) $filename = @basename($_FILES['filename']['name']); // filename of temp uploaded file $tmp_filename = $_FILES['filename']['tmp_name']; $file_ext = @strtolower(@strrchr($filename,".")); if (@strpos($file_ext,'.') === false) { // no dot? strange $errors[] = "Suspicious file name or could not determine file extension."; break; } $file_ext = @substr($file_ext, 1); // remove dot // check file type if needed if (count($exts)) { /// some day maybe check also $_FILES['user_file']['type'] if (!@in_array($file_ext, $exts)) { $errors[] = "Files of this type are not allowed for upload."; break; } } // destination filename, rename if set to $dest_filename = $filename; if (RENAME_FILE) { $dest_filename = md5(uniqid()) . '.' . $file_ext; } // get size $filesize = intval($_FILES["filename"]["size"]); // filesize($tmp_filename); // make sure file size is ok if (MAX_FILE_SIZE > 0 && MAX_FILE_SIZE*1024 < $filesize) { $errors[] = "File is too big (3)."; break; } if (!@move_uploaded_file($tmp_filename , DESTINATION_FOLDER . $dest_filename)) { $errors[] = "Could not upload file (6)."; break; } if (DO_LOG) { // Establish DB connection $link = @mysql_connect(DB_HOST, DB_USERNAME, DB_PASSWORD); if (!$link) { $errors[] = "Could not connect to mysql."; break; } $res = @mysql_select_db(DB_DATABASE, $link); if (!$res) { $errors[] = "Could not select database."; break; } $m_ip = mysql_real_escape_string($_SERVER['REMOTE_ADDR']); $m_size = $filesize; $m_fname = mysql_real_escape_string($dest_filename); $sql = "insert into _uploads_log (log_filename,log_size,log_ip) values ('$m_fname','$m_size','$m_ip')"; $res = @mysql_query($sql); if (!$res) { $errors[] = "Could not run query."; break; } @mysql_free_result($res); @mysql_close($link); } // if (DO_LOG) // redirect to upload success url //header('Location: ' . SUCCESS_URL); die(); break; } // while(true) // Errors. Show upload form. $message = join('',$errors); showUploadForm($message); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/176087-upload-form-issues-blank/ Share on other sites More sharing options...
jon23d Posted September 30, 2009 Share Posted September 30, 2009 At the risk of oversimplifying things, have you tried just a basic upload? -- The html form <form action='receiver.php' method='post' encytype='multipart/form-data'> File: <input type='file' name='file' /> <input type='submit' /> </form> -- the processer <? if (isset($_FiLES['file']['tmp_name'])) { rename($_FILES['file']['tmp_name']); ... do something with it } else { echo "Oh crap"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/176087-upload-form-issues-blank/#findComment-927839 Share on other sites More sharing options...
mbradley Posted September 30, 2009 Author Share Posted September 30, 2009 I have tried somthing simple and same thing... but this is the script or code it need to get working i will try that and see if does same thing:) edit same thing happens... even with the simplist ones as i said above sadly:( Quote Link to comment https://forums.phpfreaks.com/topic/176087-upload-form-issues-blank/#findComment-927841 Share on other sites More sharing options...
jon23d Posted September 30, 2009 Share Posted September 30, 2009 Turn on error reporting Quote Link to comment https://forums.phpfreaks.com/topic/176087-upload-form-issues-blank/#findComment-927847 Share on other sites More sharing options...
PFMaBiSmAd Posted September 30, 2009 Share Posted September 30, 2009 Find out what you are getting. Add the following in your form processing code file (outside of any logic testing $_POST or $_FILE variables...) and tell us what you get AFTER you have submitted the form - <?php 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>"; ?> And for your existing code (assuming you go forward with it), you need to post the form template file. Quote Link to comment https://forums.phpfreaks.com/topic/176087-upload-form-issues-blank/#findComment-927848 Share on other sites More sharing options...
mbradley Posted September 30, 2009 Author Share Posted September 30, 2009 Ok now here is the weird part... it is stuck saying sending info in the bar at bottem of expl and nothing else and just says "loading..." in the tab on my firefox... nothing on both... so could it be somthing with the server or host? although i really don't know what this could be? anyhelp thnx i appreciate the help already i can always count on this forum to help me Quote Link to comment https://forums.phpfreaks.com/topic/176087-upload-form-issues-blank/#findComment-927906 Share on other sites More sharing options...
eatfishy Posted September 30, 2009 Share Posted September 30, 2009 I was in the same situation as you a few days ago. I turned all the error report and didn't see any errors. I also check my script so many times and logically, it make sense to me. I found out that there's some PHP server configation that I had to do. 1) Ensure your .ini setting is set to upload file, the the size limitation, etc 2) Ensure that you set the path to the temporary upload on your server setting( I know my default temp path didn't work and I changed it to the temp path that I want). 3)If it still doesn't work, you can contact me on www.blogoberry.com since I check that website a few times a day. Quote Link to comment https://forums.phpfreaks.com/topic/176087-upload-form-issues-blank/#findComment-927916 Share on other sites More sharing options...
mbradley Posted September 30, 2009 Author Share Posted September 30, 2009 2) Ensure that you set the path to the temporary upload on your server setting( I know my default temp path didn't work and I changed it to the temp path that I want). now that is the only thing i have not had done b4 i think that might be it explain are u talking about the Tmp dir that when u upload somthing it goes too b4 it moves or somthing like that? i am sorry i feel like a idiot for this kind of thing ... deal with teh coding and not the server setup and such... so ... i have feeling might be somthing about tmp dir in the godaddy thing but i am not sure at alll:( thnx again Quote Link to comment https://forums.phpfreaks.com/topic/176087-upload-form-issues-blank/#findComment-927920 Share on other sites More sharing options...
eatfishy Posted September 30, 2009 Share Posted September 30, 2009 Yes. When you upload an image, it doesn't go straight to the path you want. It goes to the temp path first and then the actual path you want. You need to specify the temp path. 1) Specify the temp path in your PHP script. 2) Set the server temp path to the same as your PHP script. (I'm sure the Go Daddy IT team can show u this) I can show u some example once I get home. Quote Link to comment https://forums.phpfreaks.com/topic/176087-upload-form-issues-blank/#findComment-927925 Share on other sites More sharing options...
mbradley Posted September 30, 2009 Author Share Posted September 30, 2009 Ok i will call godaddy and talk to them if it does not work still i will then leave my results on here on that thnx again i hope this fixs it Quote Link to comment https://forums.phpfreaks.com/topic/176087-upload-form-issues-blank/#findComment-927932 Share on other sites More sharing options...
mbradley Posted September 30, 2009 Author Share Posted September 30, 2009 update: Tried to change the tmp folder and do the bug report on it due to new version didn't have / at the end.. /tmp/ and still not working now using this code below and still does not produce any errors or anything just keeps "thinking" and nothing comes about and goes back to form again with no change:( <?php error_reporting(E_ALL); ini_set('display_errors', 'on'); if( empty($_FILES) ) { ?> <!-- The data encoding type, enctype, MUST be specified as below --> <form enctype="multipart/form-data" action="upload.php" method="POST"> <!-- MAX_FILE_SIZE must precede the file input field --> <input type="hidden" name="MAX_FILE_SIZE" value="30000" /> <!-- Name of input element determines name in $_FILES array --> Send this file: <input name="userfile" type="file" /> <input type="submit" value="Send File" /> </form> <?php } else { $uploadfile = dirname(__FILE__).'/upload_file.test'; echo '<pre>'; if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) { echo "File is valid, and was successfully uploaded.\n"; } else { echo "Possible file upload attack!\n"; } echo 'Here is some more debugging info:'; print_r($_FILES); print "</pre>"; } ?> So am at a loss as to what could be happening if anything:( Quote Link to comment https://forums.phpfreaks.com/topic/176087-upload-form-issues-blank/#findComment-927990 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.