PHP - Post_max_size Expanded From 8m To 100m, But I Can Not Upload Larger Than Cca2m?
Hi, I created the code below for uploading anywhere from 1-15 PDF files at once. Originally I was hitting 8M limit and (as per my research) I asked my server admin to expand the post_max_size to 100M. Now he did and I verified it, but somehow now I can not upload more than cca 2MB files. What could be causing that? Thanks
Code: [Select] $forms = array("form_1", "form_1A", "form_1B", "research_plan", "abstract", "form_1C", "form_2", "form_3", "form_4", "human_consent", "form_5A", "form_5B", "form_6A", "form_6B", "form_7"); foreach ($forms as $form_name) { if ($_FILES[$form_name]['name'] != "") { $allowed_filetypes = array('.pdf','.PDF'); $max_filesize = 104857600; $upload_path = 'upload/'; $extension = substr($_FILES[$form_name]['name'], strpos($_FILES[$form_name]['name'],'.'), strlen($_FILES[$form_name]['name'])-1); $filesize = filesize($_FILES[$form_name]['tmp_name']); $filesize_MB = $filesize / 1048576; $full_name = $_FILES[$form_name]['name']; $filename = "$_REQUEST[project_no] - $form_name$extension"; if (!in_array($extension,$allowed_filetypes)) {$error_1 = "yes";} if (filesize($_FILES[$form_name]['tmp_name']) > $max_filesize) {$error_2 = "yes";} if ($error_1 == "yes") { echo "One or more of the uploaded froms are not in allowed file format. Please upload only <strong>.pdf</strong> files <br/><br/><INPUT TYPE='button' VALUE='Go Back' onClick='history.go(-1);'>"; die (); } if ($error_2 == "yes") { echo "Maximum upload file size of <strong>100MB</strong> has been reached. <br/><br/><INPUT TYPE='button' VALUE='Go Back' onClick='history.go(-1);'>"; die (); } move_uploaded_file($_FILES[$form_name]['tmp_name'],$upload_path . $filename); mysql_query("UPDATE project_registrations SET $form_name = 'yes' WHERE project_no = '$_REQUEST[project_no]'"); } } echo "ISEF files for project number <strong>$_REQUEST[project_no]</strong> have been successfully uploaded."; mysql_query("UPDATE project_registrations SET isef_forms = 'yes' WHERE project_no = '$_REQUEST[project_no]'"); require ("upload_forms_email.php"); echo "<script language='javascript'> window.location.href='search_results.php?project_no=$_REQUEST[project_no]';</script>"; Similar TutorialsAs we know , A post_max_size used to limit the size of posted data via POST method while the upload_max_filesize used to limit the size of file to be uploaded
I assume. post_max_size = 8m upload_max_filesize = 2m
When i limit the user to only upload 100kb file, i say <pre>
if (!empty($_FILES["myfile"]["tmp_name"]) && ($_FILES["myfile"]["size"] > 100000)) { </pre>
This message occur even when the file is greater than 8 m
The problem come when the file is greater than 10m the warning message for post content is on the page is
Warning: POST Content-Length of 9767236 bytes exceeds the limit of 8388608 bytes in Unknown on line 0
What i want? I want to create my own warning as an error
ie <pre>
if (post_max_size > 18388608)) { </pre>
NB: some developers says we have to adjust the post_max_size i.e 200M what if user upload the file with 210M, the warning message will come back again
Warning: POST Content-Length of 9767236 bytes exceeds the limit of 8388608 bytes in Unknown on line 0
In short i want to give a normal user a meaningful warning
Seems this should be easy, but I'm not finding the solution. Functions like scandir, readdir, and glob that I've been looking at all seem to need me to actually know more about my directory path than I can ahead of time. Here's what I want to do: 1. expand a .tar file (consists of directory, subdirectories, files, and is variable) that I've uploaded to the server 2. look through that expanded directory for a subdirectory named ".pn" -- (note that all my .tar files will have this folder deep in several subdirectories that will be variable in number and have different names depending on the original .tar file) 3. copy the entire contents of the .pn folder to another folder already on my server The hosting company, no doubt, has likely blocked some of the functions I'll need as well, but if someone can point me in the right direction to start, it would be greatly appreciated. Thanks! Satre Hello Forums, So basically I am trying to place text over an image. It works but the max text size is 5 which is way too small for my needs! What can I do to increase the size of the text? If anyone can help it would be much appreciated. Here is my code: Code: [Select] <?php $title = $_REQUEST['title'] ; $my_img = imagecreatefrompng ( "Template.png" ); $text_color = imagecolorallocate( $my_img, 0, 0, 0 ); imagestring( $my_img, 5, 30, 25, "$title", $text_colour ); header( "Content-type: image/png" ); imagepng( $my_img ); imagecolordeallocate( $text_color ); imagedestroy( $my_img ); ?> I have a website here [redacted] and it is an affiliate website where I just find products and promote them. All I have to do is give product a title, affiliate url, the description, an image and a price. I am trying to make the product description area hold more text than it does now, because at the moment in the admin side of my website it says "product description 275 max characters" That is really a short sentence. Can anyone please help me I have no php skills but really wish I did, if you need more info I will be happy to share anything I need to. Edited October 27, 2019 by requinixremoved link When I upload files > 2MB, I get an "Internal Server Error" and in the errors log see "Premature end of script headers:..." No problem with smaller files. I'm running PHP 5.28 and have the following in php5.ini. magic_quotes_gpc = Off log_errors = on display_errors = off memory_limit = 64M post_max_size = 8M upload_max_filesize = 8M max_input_time = 360 max_execution_time = 360 upload_tmp_dir = amd_temp The permissions for the upload folder are set to 755. Here's the code: <?php if ($_SERVER['REQUEST_METHOD'] == 'GET') { ?> <form method="post" action="<?php echo $_SERVER['SCRIPT_NAME'] ?>" enctype="multipart/form-data"> <input type="file" name="document"/> <input type="submit" value="Send File"/> </form> <?php } else { if (isset($_FILES['document']) && ($_FILES['document']['error'] == UPLOAD_ERR_OK)) { $newPath = 'updocs/' . basename($_FILES['document']['name']); if (move_uploaded_file($_FILES['document']['tmp_name'], $newPath)) { print "File saved in $newPath"; } else { print "Couldn't move file to $newPath"; } } else { print "No valid file uploaded."; } } ?> Any thoughts on what might be the problem? Thanks. This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=317036.0 I have code written for image uploading, but it doesn't allow multiple images on a single upload, and doesn't re-size. Anyone willing to share a good upload script that will do the following?: -Allow multiple image uploads (10+ per submission), -Re-size images on upload, and -Rename images. Thanks Brett Hi everyone, I have a page that i use to upload images to my website, i got a bit fed up of uploading one at a time so i decided to add multiple file fields to the form to upload multiple images at the same time. Im having a few problems, iv read up he http://www.php.net/manual/en/features.file-upload.multiple.php and it seems all i have to do is add [] to the form names to turn them into arrays. However when i come to upload the images, i keep getting the "$error[] = "Incorrect format!...." error from the code below. I cant seem to figure out what the problem is. Could anybody please point me in the right direction? <?php session_start(); $id = $_SESSION['id']; $connect = mysql_connect("localhost","leemp5_admin","p7031521"); mysql_select_db("leemp5_database"); $query = mysql_query("SELECT * FROM users WHERE id='$id'"); $row = mysql_fetch_assoc($query); $username = $row['username']; $submit = $_POST['submit']; $type = $_FILES['image']['type']; $size = $_FILES['image']['size']; $max_size = "1000"; $width = "100"; $height = "100"; $error = array(); function make_thumb($image_name,$filename,$new_width,$new_height) { $ext=getExtension($image_name); if(!strcmp("jpg",$ext) || !strcmp("jpeg",$ext)) $source_image=imagecreatefromjpeg($image_name); if(!strcmp("png",$ext)) $source_image=imagecreatefrompng($image_name); if(!strcmp("gif",$ext)) $source_image=imagecreatefromgif($image_name); $old_x=imageSX($source_image); $old_y=imageSY($source_image); $ratio1=$old_x/$new_width; $ratio2=$old_y/$new_height; if($ratio1>$ratio2) { $thumb_width=$new_width; $thumb_height=$old_y/$ratio1; } else { $thumb_height=$new_height; $thumb_width=$old_x/$ratio2; } $destination_image=ImageCreateTrueColor($thumb_width,$thumb_height); imagecopyresampled($destination_image,$source_image,0,0,0,0,$thumb_width,$thumb_height,$old_x,$old_y); if(!strcmp("jpg",$ext) || !strcmp("jpeg",$ext)) { imagejpeg($destination_image,$filename); } if(!strcmp("png",$ext)) { imagepng($destination_image,$filename); } if(!strcmp("gif",$ext)) { imagegif($destination_image,$filename); } imagedestroy($destination_image); imagedestroy($source_image); } function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } if($submit) { $image=$_FILES['image']['name']; if ($image) { $filename = stripslashes($_FILES['image']['name']); $extension = getExtension($filename); $extension = strtolower($extension); if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) { $error[] = "Incorrect format! Please make sure your image is a .jpg, .jpeg, .png or .gif file."; } else { $size=getimagesize($_FILES['image']['tmp_name']); $sizekb=filesize($_FILES['image']['tmp_name']); if ($sizekb > $max_size*1024) { $error[] = "Your image is too big! The maximum upload size is 1MB."; } else { $image_name=time().'.'.$extension; $newname="uploads/" . $username . "/images/".$image_name; $copied = copy($_FILES['image']['tmp_name'], $newname); if (!$copied) { $error[] = "There was an error uploading your image. Please try again!"; } else { $thumb_name='uploads/' . $username . '/images/thumbs/thumb_'.$image_name; $thumb=make_thumb($newname,$thumb_name,$width,$height); } } } } else { $error[] = "Please select an image to upload!"; } if(empty($error)) { echo "Upload Successfully!<br />"; echo '<img src="'.$thumb_name.'">'; mysql_query("INSERT INTO images VALUES ('','$username','$image_name','','','','','uploads/$username/images/$image_name','uploads/$username/images/thumbs/thumb_$image_name','$type','$size')"); } else { echo implode($error); } } ?> <form method="post" enctype="multipart/form-data" action="upload_images.php"> <input type="file" name="image[]" /><br /> <input type="file" name="image[]" /><br /> <input type="file" name="image[]" /><br /> <input type="file" name="image[]" /><br /> <input type="file" name="image[]" /><br /> <input type="file" name="image[]" /><br /> <input type="submit" name="submit" value="Upload"> </form> Thanks Stumped! I have a client who has a form where they upload files to their server: title, two password fields, and the file
They have been unable to upload anything over 10m
Small (under 10mb) files work.
Larger doesn’t
I’ve tracked it down, I think, that the processing page appears to be dropping the form values when the file takes a bit to upload.
I echo’ed the values that are grabbed from the form, and they return empty strings if it takes a while for the file to upload (a large file) - they pass fine if the file is smaller.
I think I've got the php info set correctly, but cannot for the life of me figure out how to adjust the timing out issue, or even where to troubleshoot.
Here's my phpinfo:
Max Requests
Per Child: 750 - Keep Alive: off - Max Per Connection: 100
Timeouts
Connection: 120 - Keep-Alive: 5
Directive
Local Value
Master Value
allow_call_time_pass_reference
Off
Off
allow_url_fopen
On
On
allow_url_include
Off
Off
always_populate_raw_post_data
Off
Off
arg_separator.input
&
&
arg_separator.output
&
&
asp_tags
Off
Off
auto_append_file
no value
no value
auto_globals_jit
On
On
auto_prepend_file
no value
no value
browscap
/etc/browscap.ini
/etc/browscap.ini
default_charset
no value
no value
default_mimetype
text/html
text/html
define_syslog_variables
Off
Off
disable_classes
no value
no value
disable_functions
leak,posix_getpwuid,posix_getpwnam,posix_getgrid,posix_getgrnam,posix_getgroups
leak,posix_getpwuid,posix_getpwnam,posix_getgrid,posix_getgrnam,posix_getgroups
display_errors
Off
Off
display_startup_errors
Off
Off
doc_root
no value
no value
docref_ext
no value
no value
docref_root
no value
no value
enable_dl
Off
Off
error_append_string
no value
no value
error_log
/mnt/Target01/337846/945285/www.dermerrealestate.com/logs/php_errors.log
no value
error_prepend_string
no value
no value
error_reporting
30711
30711
exit_on_timeout
Off
Off
expose_php
Off
Off
extension_dir
/usr/lib64/php/modules
/usr/lib64/php/modules
file_uploads
On
On
highlight.bg
#FFFFFF
#FFFFFF
highlight.comment
#FF8000
#FF8000
highlight.default
#0000BB
#0000BB
highlight.html
#000000
#000000
highlight.keyword
#007700
#007700
highlight.string
#DD0000
#DD0000
html_errors
On
On
ignore_repeated_errors
Off
Off
ignore_repeated_source
Off
Off
ignore_user_abort
Off
Off
implicit_flush
Off
Off
include_path
.:/usr/share/pear:/usr/share/php
.:/usr/share/pear:/usr/share/php
log_errors
On
On
log_errors_max_len
1024
1024
magic_quotes_gpc
On
On
magic_quotes_runtime
Off
Off
magic_quotes_sybase
Off
Off
mail.add_x_header
On
On
mail.force_extra_parameters
no value
no value
mail.log
no value
no value
max_execution_time
30
30
max_file_uploads
20
20
max_input_nesting_level
64
64
max_input_time
60
60
max_input_vars
1000
1000
memory_limit
128M
128M
open_basedir
no value
no value
output_buffering
no value
no value
output_handler
no value
no value
post_max_size
8M
8M
precision
14
14
realpath_cache_size
4M
4M
realpath_cache_ttl
120
120
register_argc_argv
On
On
register_globals
Off
Off
register_long_arrays
On
On
report_memleaks
On
On
report_zend_debug
On
On
request_order
no value
no value
safe_mode
Off
Off
safe_mode_exec_dir
no value
no value
safe_mode_gid
Off
Off
safe_mode_include_dir
no value
no value
sendmail_from
no value
no value
sendmail_path
/usr/sbin/sendmail -t -i
/usr/sbin/sendmail -t -i
serialize_precision
100
100
short_open_tag
On
On
SMTP
localhost
localhost
smtp_port
25
25
sql.safe_mode
Off
Off
track_errors
Off
Off
unserialize_callback_func
no value
no value
upload_max_filesize
8M
8M
upload_tmp_dir
/tmp
/tmp
user_dir
no value
no value
user_ini.cache_ttl
300
300
user_ini.filename
.user.ini
.user.ini
variables_order
EGPCS
EGPCS
xmlrpc_error_number
0
0
xmlrpc_errors
Off
Off
y2k_compliance
On
On
zend.enable_gc
On
On
files that upload during insert/submit form was gone , only files upload during the update remain , is the way query for update multiple files is wrong ? $targetDir1= "folder/pda-semakan/ic/"; if(isset($_FILES['ic'])){ $fileName1 = $_FILES['ic']['name']; $targetFilePath1 = $targetDir1 . $fileName1; //$main_tmp2 = $_FILES['ic']['tmp_name']; $move2 =move_uploaded_file($_FILES["ic"]["tmp_name"], $targetFilePath1); } $targetDir2= "folder/pda-semakan/sijil_lahir/"; if(isset($_FILES['sijilkelahiran'])){ $fileName2 = $_FILES['sijilkelahiran']['name']; $targetFilePath2 = $targetDir2 . $fileName2; $move3 =move_uploaded_file($_FILES["sijilkelahiran"]["tmp_name"], $targetFilePath2); } $targetDir3= "folder/pda-semakan/sijil_spm/"; if(isset($_FILES['sijilspm'])){ $fileName3 = $_FILES['sijilspm']['name']; $targetFilePath3 = $targetDir3 . $fileName3; $move4 =move_uploaded_file($_FILES["sijilspm"]["tmp_name"], $targetFilePath3); } $query1=("UPDATE semakan_dokumen set student_id='$noMatrik', email= '$stdEmail', surat_tawaran='$fileName', ic='$fileName1',sijil_lahir='$fileName2',sijil_spm= '$fileName3' where email= '$stdEmail'");
Can someone Help me I made a code for uploading files to database.. but how can i retrieve it? Is it possible to open the pdf file in browser? Im using XAMPP MySql.. SOMEONE HELP ME PLS. Hi there We are hosting a web server that requires large files (100MB+) to be uploaded to it. We are using PHP upload scripts, and it is working, but we are getting complaints that the uploads are unreliable (some files fail to upload, with no error messages). I have been reading on various forums that FTP should rather be used for larger files, rather than HTTP. But from what I can see, there are some limitations, and I was wondering if there are any ways around these: - Using cURL would mean that the files would first be uploaded to a temp folder on the web server via HTTP, and then only sent via FTP. This defeats the purpose, because if it is already on the Web Server (which is hosted locally), then I might just as well move the file. - Using the built in FTP functionality of PHP, it appears that ones needs to know the full path of the source file. The users who are uploading files are accessing the Web server via a form in a browser, which will not give the PHP script the full path of the file to be uploaded. All we want is to have a reliable means for an end-user to access a site with a browser, fill in a form, choose a file to upload, and submit it. Additional functionality, like a progress bar, the ability to select multiple files and a resume option for failed uploads, would all be very nice. But the main concern is that the transfers be more reliable. Thanks for any advice. Mills I have made this script to upload to an ftp server. How do I get the script to try to restart the upload if it fails? (if if (ftp_put($conn_id, $remote_file, $file, FTP_ASCII)) returns false) Code: [Select] <?php $file = 'file.wmv'; $remote_file = 'file.wmv'; // set up basic connection $conn_id = ftp_connect('ftp.eu.filesonic.com'); $ftp_user_name='username'; $ftp_user_pass='password'; // login with username and password $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); // upload a file if (ftp_put($conn_id, $remote_file, $file, FTP_ASCII)) { echo "successfully uploaded $file\n"; } else { echo "There was a problem while uploading $file\n"; } // close the connection ftp_close($conn_id); ?> Hey Im trying to upload a pdf file into a blob in a database. This script worked to insert images and I made a few minor changes so that it could do the same for pdf files. Only when i run the script in a browser it says error unknown file format. I dont understand this because I do list pdf as a valid file format. The txt and the doc possible file uploads are just there to take up spots where jpeg and gif were in the picture script i have no intention of actually uploading those. The file i tested was yes a pdf so that cant be the issue. Heres the script. Code: [Select] <?php $db_host = 'localhost'; // don't forget to change $db_user = 'root'; $db_pwd = 'dbpassword'; $database = 'mydbname'; $table = 'lit_gallery'; // use the same name as SQL table $password = '123'; // simple upload restriction, // to disallow uploading to everyone if (!mysql_connect($db_host, $db_user, $db_pwd)) die("Can't connect to database"); if (!mysql_select_db($database)) die("Can't select database"); // This function makes usage of // $_GET, $_POST, etc... variables // completly safe in SQL queries function sql_safe($s){ if (get_magic_quotes_gpc()) $s = stripslashes($s); return mysql_real_escape_string($s);} // If user pressed submit in one of the forms if ($_SERVER['REQUEST_METHOD'] == 'POST'){ // cleaning title field $title = trim(sql_safe($_POST['title'])); if ($title == '') // if title is not set $title = '(empty title)'; // use (empty title) string if ($_POST['password'] != $password)// cheking passwors $msg = 'Error: wrong upload password'; else { if (isset($_FILES['book'])) { @list(, , $ftype, ) = getimagesize($_FILES['book']['tmp_name']); // Get file type. // We use @ to omit errors if ($ftype == 3) // cheking image type $ext="pdf"; // to use it later in HTTP header elseif ($ftype == 2) $ext="txt"; elseif ($imtype == 1) $ext="doc"; else $msg = 'Error: unknown file format'; if (!isset($msg)) // If there was no error { $data = file_get_contents($_FILES['book']['tmp_name']); $data = mysql_real_escape_string($data); // Preparing data to be used in MySQL query mysql_query("INSERT INTO {$table} SET ext='$ext', title='$title', data='$data'"); $msg = 'Success: pdf uploaded'; } } elseif (isset($_GET['title'])) // isset(..title) needed $msg = 'Error: file not loaded'; // to make sure we've using // upload form, not form // for deletion if (isset($_POST['del'])) // If used selected some photo to delete { // in 'uploaded images form' $id = intval($_POST['del']); mysql_query("DELETE FROM {$table} WHERE id=$id"); $msg = 'Book deleted'; } } } elseif (isset($_GET['show'])){ $id = intval($_GET['show']); $result = mysql_query("SELECT ext, UNIX_TIMESTAMP(book_time), data FROM {$table} WHERE id=$id LIMIT 1"); if (mysql_num_rows($result) == 0) die('no image'); list($ext, $book_time, $data) = mysql_fetch_row($result); $send_304 = false; if (php_sapi_name() == 'apache') { // if our web server is apache // we get check HTTP // If-Modified-Since header // and do not send image // if there is a cached version $ar = apache_request_headers(); if (isset($ar['If-Modified-Since']) && // If-Modified-Since should exists ($ar['If-Modified-Since'] != '') && // not empty (strtotime($ar['If-Modified-Since']) >= $book_time)) // and grater than $send_304 = true; // image_time } if ($send_304) { // Sending 304 response to browser // "Browser, your cached version of image is OK // we're not sending anything new to you" header('Last-Modified: '.gmdate('D, d M Y H:i:s', $ts).' GMT', true, 304); exit(); // bye-bye } // outputing Last-Modified header header('Last-Modified: '.gmdate('D, d M Y H:i:s', $book_time).' GMT', true, 200); // Set expiration time +1 year // We do not have any photo re-uploading // so, browser may cache this photo for quite a long time header('Expires: '.gmdate('D, d M Y H:i:s', $book_time + 86400*365).' GMT', true, 200); // outputing HTTP headers header('Content-Length: '.strlen($data)); header("Content-type: application/{$ext}"); // outputing book echo $data; exit(); } ?> <head> <title>MySQL Blob Image Gallery Example</title> <link rel="stylesheet" type="text/css" href="test.css"/> </head> <html> <body> <?php if (isset($msg)) // this is special section for // outputing message { ?> <p style="font-weight: bold;"><?=$msg?><br><a href="<?=$PHP_SELF?>">reload page</a><!-- I've added reloading link, because refreshing POST queries is not good idea --></p> <?php } ?> <h1>Blob image gallery</h1> <h2>Uploaded images:</h2> <form action="<?=$PHP_SELF?>" method="post"> <!-- This form is used for image deletion --> <?php $result = mysql_query("SELECT id, book_time, title FROM {$table} ORDER BY id DESC"); if (mysql_num_rows($result) == 0) // table is empty echo '<ul><li>No images loaded</li></ul>'; else{ echo '<ul>'; while(list($id, $book_time, $title) = mysql_fetch_row($result)) { // outputing list echo "<li><input type='radio' name='del' value='{$id}'>"; echo "<a href='{$PHP_SELF}?show={$id}'>{$title}</a> – "; echo "<small>{$book_time}</small></li>"; } echo '</ul>'; echo '<label for="password">Password:</label><br>'; echo '<input type="password" name="password" id="password"><br><br>'; echo '<input type="submit" value="Delete selected">'; } ?> <html> <body> </form><h2>Upload new image:</h2><form action="<?=$PHP_SELF?>" method="POST" enctype="multipart/form-data"> <label for="title">Title:</label><br><input type="text" name="title" id="title" size="64"><br> <br> <label for="book">Book:</label><br><input type="file" name="book" id="book"><br> <br> <label for="password">Password:</label><br><input type="password" name="password" id="password"><br> <br><input type="submit" value="upload"></form> </body> </html> Good day: I have a simple uploader form to upload video files. FLV and mpg files will upload without problems. But mp4, m4v, ogg and webm files will not upload. I get this error: Warning: copy() [function.copy]: Unable to access in /mounted-storage/home7/sub007/sc30390-PTUD/**********.com/admin123/insertvideo.php on line 32 Error Video not loaded. I have read about adding the files in config/mimes.php but I do not see that folder or files in my hosting service (which is servage). Any help will be appreciated. Thanks. Dear user I write a file upload code in php, the code work's fine but it will upload the file up to 60 KB, when i try to upload more then 60 KB file then the page stuck on loading. The problem is why it is not uploading more then 60kb file? is there any fault in my code please check it out.. My form.php code is... <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <link rel="stylesheet" href="css/bootstrap.css"/> <link rel="stylesheet" href="css/bootstrap.min.css"/> </head> <body> <div class="col-md-6"> <form action="upload.php" method="post" enctype="multipart/form-data"> <label for="">Item</label><br/> <input type="file" name="picture" class="form-control"><br/> <label for="">Description</label><br/> <textarea name="description" id="" placeholder="Enter Item Description" class="form-control" cols="50" rows="20"></textarea><br/> <input type="submit" name="submit" value="Upload" class="btn btn-success"> </form> </div> <script src="js/bootstrap.js"></script> <script src="js/bootstrap.min.js"></script> <script src="js/jquery-2.1.1.min.js"></script> <body> </html>my upload.php code is <?php include 'conn.php'; $desc=$_POST['description']; $image=$_FILES['picture']; $image_name=$_FILES['picture']['name']; $placed='uploads/'; if(move_uploaded_file($_FILES['picture']['tmp_name'],$placed.$image_name)) { $smt=$conn->prepare("INSERT INTO images(Image_Name,Description,Placed_On)VALUES('".$image_name."','".$desc."','".$placed."')"); $smt->execute(); header('location:form.php'); } else { echo 'error on uploading file'; } ?> When I upload files larger than appx 18M it says that the file was uploaded but it isnt. Is there snippet of code that i could put in the script to show me the upload error ? Or does anyone know what could be causing this. My php.ini settings are as follows max upload size = 50M max post size = 100M execution time = 2400 input time = 2400 I thought initially maybe it was timing out so i increased the input and the execution time value. But its still doing the same thing. -SB This is my first time ever working with this type of stuff with PHP. So, I basically got this code from a tutorial at Tizag on how to upload files to your webiste. But everytime I do, I get an error message. I don't get a PHP error, I just get it from the code. "There was an error uploading the file, please try again!" <?php session_start(); include("includes/mysql.php"); include("includes/config.php"); ?> <title><?php echo $title; ?></title> <?php if(!$_SESSION['user']) { echo "Your not allowed to upload plugins! <a href='index.php'>Go Home</a> or <a href='register.php'>Make an account</a>."; } else { $description = $_POST['description']; $description = mysql_real_escape_string($description); $ip = $_SERVER['REMOTE_ADDR']; $date = date('m-d-y'); $title = $_POST['title']; $title = mysql_real_escape_string($title); $query = mysql_query("SELECT COUNT(id) FROM mods"); $finish_query = mysql_fetch_assoc($query); $output = $finish_query['COUNT(id)'] + 1; echo $output; $_FILES['uploadedfile']['name'] = $output; echo $_FILES['uploadfile']['name']; $target_path = "mods/"; $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { echo "The mod ". basename( $_FILES['uploadedfile']['name']). " has been uploaded. Check it out HERE."; mysql_query("INSERT INTO mods VALUES('', '$ip', '$date', '$title', '$description', '$user')"); } else{ echo "There was an error uploading the file, please try again!"; } } include("includes/footer.php"); ?> I have a file upload script which is working fine but i want to change the name of the uploaded file to a session varible $_session['id']... WHat should i do... I tried to do it by writing the following the following code.... Code: [Select] $_FILES["file"]["name"]=$_SESSION['id']; But by this i looses the file extension... File can be of nay type... (.pdf, .jpg, .gif, .png) -pranshu.a.11@gmail.com I using an upload script to upload image files... but the script is not working. I have created a folder named UPLOAD at same location where the file is present. But my upload script is just creating a copy of upload.php script only but not the actual image. My code is given below : Code: [Select] if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/pjpeg")) && ($_FILES["file"]["size"] < 20000000)) { if ($_FILES["file"]["error"] > 0) { //echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { /* echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; */ // $_FILES["file"]["name"]=$_SESSION['id']; if (file_exists("upload/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]); $_SESSION['result']="SUCCESSFULLY UPDATED YOUR PROFILE"; header('location:members.php'); } } } else { echo "Invalid file"; } } What should i do.... Do i need to have some folder to store temporary files.... ???? |