Author Topic: Simplifying Image Upload  (Read 34677 times)

0 Members and 1 Guest are viewing this topic.

Offline stomi

  • Newbie
  • *
  • Posts: 10
    • View Profile
Simplifying Image Upload
« on: May 19, 2003, 11:55:26 AM »
Hi all.

I want to simplify the image upload for users.

The existing process looks like this:

First I browse the harddisk for an image file:



Then I have to choose a file-name.

I removed the thumbnail fields, because I use auto-thumbnailing.

Then i click submit and after a successful upload the following screen comes up:


---------------------------------------------

Now I got 2 requests:

At first, i don't want that "Image Name" is a mandatory field.
If the user decides to leave the "Image Name" field empty, the file name should be the Image name automatically.

Is this possible?


Second one: After successfully uploading an image, the image shouldn't be displayed. A short success message would be enough. The Image upload fields should be up again, so that the user can quickly upload another image.


Are there already mods doing that?
Is it much effort?

Help is appreciated.
Thanks, K.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Simplifying Image Upload
« Reply #1 on: May 20, 2003, 06:17:51 AM »
Quote from: stomi
Are there already mods doing that?
Is it much effort?
No ;)
Here is a quick fix for that ;)

open /member.php
find:
Code: [Select]
 if ($image_name == "")  {
    $error = 1;
    $field_error = preg_replace("/".$site_template->start."field_name".$site_template->end."/siU", str_replace(":", "", $lang['image_name']), $lang['field_required']);
    $msg .= (($msg != "") ? "<br />" : "").$field_error;
  }
comment it or simply remove it ;)
then find:
Code: [Select]
$current_time = time();add after:
Code: [Select]
if (!$image_name)
{
  $image_name = $HTTP_POST_VARS['image_name'] = get_file_name($new_name);
}
now, image name entry is not necerry, it will use filename (without extention) if its empty.


to fix the "after upload" page, just find:
Code: [Select]
$content .= "<table border=\"0\" align=\"center\">\n<tr>\n<td>\n".$media."\n</td>\n</tr>\n</table>\n";add after:
Code: [Select]
$action = "uploadform";
that's all.
but if u'd like it remmber the fields (image name, keywords, description)
also add:
Code: [Select]
$sendprocess = 1;
good luck ;)
« Last Edit: December 25, 2005, 11:20:23 AM by V@no »
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline stomi

  • Newbie
  • *
  • Posts: 10
    • View Profile
Simplifying Image Upload
« Reply #2 on: May 20, 2003, 10:10:33 AM »
yeah.. that works great.

10000000 thanks @ v@no.


now picture upload is very fast and comfortable

Offline Slammer

  • Newbie
  • *
  • Posts: 21
    • View Profile
    • http://www.mobile-snapshots.com
Simplifying Image Upload
« Reply #3 on: June 20, 2003, 01:48:06 PM »
a little question about this one, V@no you said:
Quote
open /member.php
find:Code:
  if ($image_name == "")  {
    $error = 1;
    $field_error = preg_replace("/".$site_template->start."field_name".$site_template->end."/siU", str_replace(":", "", $lang['image_name']), $lang['field_required']);
    $msg .= (($msg != "") ? "<br />" : "").$field_error;
  }

comment it or simply remove it


i my member.php there are two of these codes, does this mean i delete both of them?
thnx.
http://www.mobile-snapshots.com
made a great snapshot with your mobile? upload it now!

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Simplifying Image Upload
« Reply #4 on: June 20, 2003, 02:31:39 PM »
I dont know, because I have just one, default 4images has just one part with that code. its in if ($action == "uploadimage") {...} part (just scroll up a little bit to see what $action is being execute.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Xmode

  • Pre-Newbie
  • Posts: 6
    • View Profile
Re: Simplifying Image Upload
« Reply #5 on: June 08, 2005, 05:47:25 AM »
hey vano it doesnt work for me is there anyway i can download your member.php ? thx

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Simplifying Image Upload
« Reply #6 on: June 08, 2005, 06:06:29 AM »
hey vano it doesnt work for me
sorry to hear that.

is there anyway i can download your member.php ?
U could, but I dont think u want it. I'm 102% sure it will not work for u at all ;)
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Xmode

  • Pre-Newbie
  • Posts: 6
    • View Profile
Re: Simplifying Image Upload
« Reply #7 on: June 08, 2005, 06:33:10 AM »
why it will not work ?? is there other way ? :cry:

Offline Acidgod

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 2.421
  • It's me?
    • View Profile
    • Flash-Webdesign
Re: Simplifying Image Upload
« Reply #8 on: November 28, 2005, 01:22:28 PM »
why it will not work ??

Look at V@nos Site and you will see that he has many modifications on his Site and in the member.php...
And thats the way why his member.php dont work with your Gallery... (o:

Offline bxmas13

  • Pre-Newbie
  • Posts: 2
    • View Profile
    • Best Tasting Fat Burning Meal Replacement
Re: Simplifying Image Upload
« Reply #9 on: December 12, 2005, 08:44:43 PM »
Quote
why it will not work ?? is there other way ?

Xmode:  I made the same mistake and couldn't figure out why the changes wouldn't work.  Until I looked closer.

When you search for this:
Code: [Select]
  if ($image_name == "")  {
    $error = 1;
    $field_error = preg_replace("/".$site_template->start."field_name".$site_template->end."/siU", str_replace(":", "", $lang['image_name']), $lang['field_required']);
    $msg .= (($msg != "") ? "<br />" : "").$field_error;
  }

Make sure it is 39 lines below this code:

Code: [Select]
if ($action == "uploadimage") {

Make sure you DO NOT comment the code below this:
Code: [Select]
if ($action == "updateimage") {
Once you make those changes it will work!  :wink:
For a great-tasting, all-natural, highly nutritious fat burning meal replacement visit http://www.natural-edge.com

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Simplifying Image Upload
« Reply #10 on: December 25, 2005, 11:19:05 AM »
I just found a bug with this method, the keywords not being populated...
To fix that, in member.php instead of
Code: [Select]
$image_name = ($image_name) ? $image_name : get_file_name($new_name);use:
Code: [Select]
if (!$image_name)
{
  $image_name = $HTTP_POST_VARS['image_name'] = get_file_name($new_name);
}

P.S. I've updated my original post.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline himu

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
    • Point Of View
Re: Simplifying Image Upload
« Reply #11 on: January 26, 2006, 09:13:07 AM »
I dont know, because I have just one, default 4images has just one part with that code. its in if ($action == "uploadimage") {...} part (just scroll up a little bit to see what $action is being execute.

Interestingly i have the same issue.. follwing are the two instances of if ($action == "uploadimage") {...} if ($image_name == ""){...} part:  :roll: (I have commented them both and it seems to be working.)

Line 329 - 359
Code: [Select]
if ($action == "updateimage") {
  if (!$image_id || ($config['user_edit_image'] != 1 && $user_info['user_level'] != ADMIN)) {
    show_error_page($lang['no_permission']);
  }
  $sql = "SELECT image_id, cat_id, user_id, image_name
          FROM ".IMAGES_TABLE."
          WHERE image_id = $image_id";
  $image_row = $site_db->query_firstrow($sql);
  if (!$image_row || $image_row['user_id'] <= USER_AWAITING || ($user_info['user_id'] != $image_row['user_id'] && $user_info['user_level'] != ADMIN)) {
    show_error_page($lang['no_permission']);
    exit;
  }

  $txt_clickstream = get_category_path($image_row['cat_id'], 1).$config['category_separator']."<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$image_id)."\" class=\"clickstream\">".$image_row['image_name']."</a>".$config['category_separator'];
  $txt_clickstream .= $lang['image_edit'];

  $error = 0;

  $image_preview = (isset($HTTP_POST_VARS['image_preview'])) ? 1 : 0;
  $image_name = un_htmlspecialchars(trim($HTTP_POST_VARS['image_name']));
  $image_description = un_htmlspecialchars(trim($HTTP_POST_VARS['image_description']));
  $image_keywords = un_htmlspecialchars(trim($HTTP_POST_VARS['image_keywords']));
  $image_keywords = preg_replace("/[\n\r]/is", " ", $image_keywords);
  $image_keywords = str_replace(","," ",$image_keywords);
  $image_keywords = ereg_replace("( ){2,}", " ", $image_keywords);

//  if ($image_name == "")  {
//    $error = 1;
//    $field_error = preg_replace("/".$site_template->start."field_name".$site_template->end."/siU", str_replace(":", "", $lang['image_name']), $lang['field_required']);
//    $msg .= (($msg != "") ? "<br />" : "").$field_error;
//  }

Line 491 - 537
Code: [Select]
if ($action == "uploadimage") {
  if ($cat_id != 0 && (!isset($cat_cache[$cat_id]) || !check_permission("auth_upload", $cat_id))) {
    show_error_page($lang['no_permission']);
    exit;
  }

  $txt_clickstream = "";
  if ($cat_id && isset($cat_cache[$cat_id])) {
    $txt_clickstream .= get_category_path($cat_id, 1).$config['category_separator'];
  }
  $txt_clickstream .= $lang['user_upload'];

  $remote_media_file = format_url(un_htmlspecialchars(trim($HTTP_POST_VARS['remote_media_file'])));
  $remote_thumb_file = format_url(un_htmlspecialchars(trim($HTTP_POST_VARS['remote_thumb_file'])));

  $image_preview = (isset($HTTP_POST_VARS['image_preview'])) ? 1 : 0;
  $image_name = un_htmlspecialchars(trim($HTTP_POST_VARS['image_name']));
  $image_description = un_htmlspecialchars(trim($HTTP_POST_VARS['image_description']));
  $image_keywords = un_htmlspecialchars(trim($HTTP_POST_VARS['image_keywords']));
  $image_keywords = preg_replace("/[\n\r]/is", " ", $image_keywords);
  $image_keywords = str_replace(","," ",$image_keywords);
  $image_keywords = ereg_replace("( ){2,}", " ", $image_keywords);

  $image_active = (isset($HTTP_POST_VARS['image_active']) && $HTTP_POST_VARS['image_active'] == 0) ? 0 : 1;
  $image_allow_comments = (isset($HTTP_POST_VARS['image_allow_comments']) && $HTTP_POST_VARS['image_allow_comments'] == 0) ? 0 : 1;
  $image_download_url = (isset($HTTP_POST_VARS['image_download_url'])) ? format_url(un_htmlspecialchars(trim($HTTP_POST_VARS['image_download_url']))) : "";

  $direct_upload = (check_permission("auth_directupload", $cat_id)) ? 1 : 0;
  $upload_cat = ($direct_upload) ? $cat_id : 0;

  $error = 0;
  $uploaderror = 0;

  if ($cat_id == 0)  {
    $error = 1;
    $field_error = preg_replace("/".$site_template->start."field_name".$site_template->end."/siU", str_replace(":", "", $lang['category']), $lang['field_required']);
    $msg .= (($msg != "") ? "<br />" : "").$field_error;
  }
  if ((empty($HTTP_POST_FILES['media_file']['tmp_name']) || $HTTP_POST_FILES['media_file']['tmp_name'] == "none") && ($remote_media_file == "" || !check_remote_media($remote_media_file))) {
    $error = 1;
    $msg .= (($msg != "") ? "<br />" : "").$lang['image_file_required'];
  }
//  if ($image_name == "")  {
//    $error = 1;
//    $field_error = preg_replace("/".$site_template->start."field_name".$site_template->end."/siU", str_replace(":", "", $lang['image_name']), $lang['field_required']);
//    $msg .= (($msg != "") ? "<br />" : "").$field_error;
//  }

any clues?

2nd question:
How can i replace the (_) underscores of file name to ( ) spaces in the Image Name?

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Simplifying Image Upload
« Reply #12 on: January 26, 2006, 02:49:29 PM »
any clues?
The first instance is for edit images, you should leave it intact, but the second instanse is what you are looking for.

2nd question:
How can i replace the (_) underscores of file name to ( ) spaces in the Image Name?
replace
Code: [Select]
  $image_name = $HTTP_POST_VARS['image_name'] = get_file_name($new_name);with:
Code: [Select]
  $image_name = $HTTP_POST_VARS['image_name'] = str_replace("_", " ", str_replace("%20", " ", get_file_name($new_name)));
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline himu

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
    • Point Of View
Re: Simplifying Image Upload
« Reply #13 on: January 26, 2006, 04:38:42 PM »
Awesome... Thanks! V@no... u the man.

Offline spiritwolf2000

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Simplifying Image Upload
« Reply #14 on: March 26, 2006, 05:43:01 AM »
I have this code in my member.php file:

Code: [Select]
      $content .= "<table border=\"0\" align=\"center\">\n<tr>\n<td>\n".$media."\n</td>\n</tr>\n</table>\n";
    }
    else {
      $action = "uploadform";
      $sendprocess = 1;
    }
  }
  else {
    $action = "uploadform";
    $sendprocess = 1;
  }
}

But its not working.  This is straight from the original member.php file with 1.7.2...  But yet on my other site with the same code it is working?!?  Any suggestions would be appreciated!  It was working before applying the update.