dennismonsewicz Posted April 8, 2008 Share Posted April 8, 2008 I am trying to upload an image that is 4.5MB and my script is set to upload up to 3GB (JUST FOR TESTING) and for some reason the file doesn't upload. A link to the file appears but the actual upload does not happen. here is my code <?php include "includes/header.php"; include "includes/sidebar.php"; ?> <div class="maincontent"> <?php $_SESSION['username'] = $_GET['username']; if($_POST['categories']) { // ============== // Configuration // ============== $uploaddir = "imageuploads"; // Where you want the files to upload to - Important: Make sure this folders permissions is 0777! $allowed_ext = "pjpg, jpg"; // These are the allowed extensions of the files that are uploaded $max_size = "3221225472"; // 50000 is the same as 50kb $max_height = ""; // This is in pixels - Leave this field empty if you don't want to upload images $max_width = ""; // This is in pixels - Leave this field empty if you don't want to upload images $uploaded_by = $_SESSION['username']; $name = $_FILES['file']['name']; $filesize = $_FILES['file']['size']; $filetype = $_FILES['file']['type']; $url = "http://intranet.healthresources.net/hrstock/" . $uploaddir; $categories = $_POST['categories']; // Check Entension $extension = pathinfo($_FILES['file']['name']); $extension = $extension[extension]; $allowed_paths = explode(", ", $allowed_ext); for($i = 0; $i < count($allowed_paths); $i++) { if ($allowed_paths[$i] == "$extension") { $ok = "1"; } } // Check File Size if ($ok == "1") { if($_FILES['file']['size'] > $max_size) { print "File size is too big!"; exit; } // Check Height & Width if ($max_width && $max_height) { list($width, $height, $type, $w) = getimagesize($_FILES['file']['tmp_name']); if($width > $max_width || $height > $max_height) { print "File height and/or width are too big!"; exit; } } // The Upload Part if(is_uploaded_file($_FILES['file']['tmp_name'])) { move_uploaded_file($_FILES['file']['tmp_name'],$uploaddir.'/'.$_FILES['file']['name']); } echo "<div class='maincontentheader'> <h2>" . ucwords($_SESSION['username']) . ", thank you for your upload!</h2> </div>"; echo "<p>Your file has been uploaded successfully! Yay!</p>"; echo "<p> </p>"; echo "<p><a href='upload.php?username=" . $_SESSION['username'] . "'>Upload another?</a></p>"; include "includes/sql.php"; $query = "insert into uploads (username, name, size, type, url, categories, number_of_downloads) " . "values ('$uploaded_by', '$name', '$filesize', '$filetype', '$url', '$categories', '0')"; mysql_query($query) or die("ERROR: " . mysql_error()); //on-th-fly thumbnail generator include "thumbtest.php"; } else { print "Incorrect file extension!"; } } else { echo '<div class="maincontentheader"> <h2>' . ucwords($_SESSION['username']) . ', use the form below to upload an image!</h2> </div> <p>Make sure to add categories to this image.</p> <p> </p> <p>Adding categories allows for the image to show up during an image search!</p> <p> </p> <p>Example Categories: Cat, Dog, Ocean, Older Male, Female, etc...</p> <p> </p> <p style="font-size: 80%"><b>Note: if you have more than one category please make sure to separate them by a comma!</b></p> <p> </p> <!-- The data encoding type, enctype, MUST be specified as below --> <form enctype="multipart/form-data" action="upload.php?username=' . $_SESSION['username'] . '" method="POST" name="uploadfile"> <!-- Name of input element determines name in $_FILES array --> <p>Image Categories: <input name="categories" type="text" /></p> <p> </p> <p>Upload this file: <input name="file" type="file" /></p> <p><input type="submit" value="Upload File" /></p> </form>'; } ?> <div class="maincontentfooter"> </div> </div> <?php include "includes/footer.php"; ?> Link to comment https://forums.phpfreaks.com/topic/100185-solved-image-doesnt-upload/ Share on other sites More sharing options...
craygo Posted April 8, 2008 Share Posted April 8, 2008 you can't set an upload size within a script. the max_upload_size is in the php.ini file. The default is 2MB. So if you do not have access to the php.ini file then you are SOL. Ray Link to comment https://forums.phpfreaks.com/topic/100185-solved-image-doesnt-upload/#findComment-512242 Share on other sites More sharing options...
dennismonsewicz Posted April 8, 2008 Author Share Posted April 8, 2008 I am actually about to go reset that... I shall let you know what happens Link to comment https://forums.phpfreaks.com/topic/100185-solved-image-doesnt-upload/#findComment-512252 Share on other sites More sharing options...
craygo Posted April 8, 2008 Share Posted April 8, 2008 you may want to change a couple others also ;;;;;;;;;;;;;;;;;;; ; Resource Limits ; ;;;;;;;;;;;;;;;;;;; max_execution_time = 900 ; Maximum execution time of each script, in seconds max_input_time = 900 ; Maximum amount of time each script may spend parsing request data memory_limit = 64M ; Maximum amount of memory a script may consume (8MB) along with ; Maximum allowed size for uploaded files. upload_max_filesize = 10M Ray Link to comment https://forums.phpfreaks.com/topic/100185-solved-image-doesnt-upload/#findComment-512254 Share on other sites More sharing options...
dennismonsewicz Posted April 8, 2008 Author Share Posted April 8, 2008 Thanks for the suggestions. I fixed my problem. Gotta love optimization Link to comment https://forums.phpfreaks.com/topic/100185-solved-image-doesnt-upload/#findComment-512275 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.