what is you current script? (don't post the classes here)
Combine the multiple and resize
(26 posts) Great offers for webmaster, blogger and web developer!-
Posted 1 year ago #
-
What do you mean? Do you want me to post the foto_upload script here?
Posted 1 year ago # -
Quote from: surveyman
"What do you mean? Do you want me to post the foto_upload script here?"only your modified code (I know my own scripts/code)
Posted 1 year ago # -
I kept most of the default since like I said before I am a PHP noob but this is where I started editing the foto_upload script:
$max_size = 1024*1024; // the max. size for uploading (~1MB) define("MAX_SIZE", $max_size); $foto_upload = new Foto_upload; $foto_upload->upload_dir = $_SERVER['DOCUMENT_ROOT']."/images/"; // "files" is the folder for the uploaded files (you have to create these folder) $foto_upload->foto_folder = $_SERVER['DOCUMENT_ROOT']."/images/gallery/"; $foto_upload->thumb_folder = $_SERVER['DOCUMENT_ROOT']."/images/gallery/"; $foto_upload->extensions = array(".jpg"); // specify the allowed extension(s) here $foto_upload->language = "en"; $foto_upload->x_max_size = 9000; $foto_upload->y_max_size = 9000; $foto_upload->x_max_thumb_size = 600; $foto_upload->y_max_thumb_size = 600; if (isset($_POST['Submit']) && $_POST['Submit'] == "Upload") { foreach ($_FILES as $key => $val) { $foto_upload->the_temp_file = $_FILES['upload']['tmp_name']; $foto_upload->the_file = $_FILES['upload']['name']; $foto_upload->http_error = $_FILES['upload']['error']; $foto_upload->replace = (isset($_POST['replace'])) ? $_POST['replace'] : "n"; // because only a checked checkboxes is true $foto_upload->do_filename_check = "n"; if ($foto_upload->upload()) { $foto_upload->process_image(false, true, true, 80); $foto_upload->message[] = "Processed foto: ".$foto_upload->file_copy."!"; // "file_copy is the name of the foto" echo '<img src="../images/gallery/'.$foto_upload- />file_copy.'">'; } } } $error = $foto_upload->show_error_string(); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Photo-upload form</title> <style type="text/css"> <!-- body { text-align:center; } label { margin:0; float:left; display:block; width:120px; } #main { width:350px; margin:0 auto; padding:20px 0; text-align:left; } --> </style> </head> <body> <div id="main"> <h1>Photo-upload form</h1> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data"> <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_size; ?>"><br /> <div> <label for="upload">Select a foto</label> <input type="file" name="upload[]" size="35"> <input type="file" name="upload[]" size="35"> <input type="file" name="upload[]" size="35"> <input type="file" name="upload[]" size="35"> </div> <div> <label for="replace">Replace an old foto?</label> <input type="checkbox" name="replace" value="y"></div> <p style="margin-top:25px;text-align:center;"><input type="submit" name="Submit" id="Submit" value="Upload"> </p> </form> <p><?php echo $error; ?></p> </div> </body> </html>As you can see it is pretty much the default with the exception of what you told me yesterday.
Posted 1 year ago # -
You didn't use these IMPORTANT rows of code:
$foto_upload->the_temp_file = $_FILES[$key]['tmp_name']; $foto_upload->the_file = $val; $foto_upload->http_error = $_FILES[$key]['error'];replace this code with (the old)
$foto_upload->the_temp_file = $_FILES['upload']['tmp_name']; $foto_upload->the_file = $_FILES['upload']['name']; $foto_upload->http_error = $_FILES['upload']['error'];Posted 1 year ago # -
Now I have this:
if (isset($_POST['Submit']) && $_POST['Submit'] == "Upload") { foreach ($_FILES as $key => $val) { $foto_upload->the_temp_file = $_FILES[$key]['tmp_name']; $foto_upload->the_file = $val; $foto_upload->http_error = $_FILES[$key]['error']; $foto_upload->replace = (isset($_POST['replace'])) ? $_POST['replace'] : "n"; // because only a checked checkboxes is true $foto_upload->do_filename_check = "n"; if ($foto_upload->upload()) { $foto_upload->process_image(false, true, true, 80); $foto_upload->message[] = "Processed foto: ".$foto_upload->file_copy."!"; // "file_copy is the name of the foto" echo '<img src="../images/gallery/'.$foto_upload- />file_copy.'">'; } } }I am still getting the error:
Notice: Array to string conversion in /home/wickedw1/public_html/upload/upload_class.php on line 89and
Only files with the following extensions are allowed: .jpg
I am still uploading a jpg file. I know I am hassling you, but I really like the script and would love it to work with both.
Posted 1 year ago # -
which one is row 89?
Only files with the following extensions are allowed: .jpg
I think this error is related to the first error
Posted 1 year ago # -
Ok I did some research and I think that the
function check_file_name($the_name) { if ($the_name != "") { if (strlen($the_name) > $this->max_length_filename) { $this->message[] = $this->error_text(13); return false; } else {is causing the error. It looks to me that $the_name is being pulled as an array and not a string. Is there a way to get this to be pulled as a string?
Posted 1 year ago # -
what is the row 89?
Posted 1 year ago # -
row 89 is:
if (strlen($the_name) > $this->max_length_filename) {i think the strlen is trying to convert $the_name to a string but it is coming in as an array.
Posted 1 year ago #
Topic Closed
This topic has been closed to new replies.