Page 14 of 23 FirstFirst ... 41213141516 ... LastLast
Results 196 to 210 of 340

Thread: How to: Upload images using PHP

  1. #196
    Join Date
    Mar 2005
    I think I've solved my problem - I don't store the whole pathway to the file in the db, hope the script works fine once it is online...
    I think it should be also noted in the original tutorial that this scripts works basically for ANY type of files, not only for images.

  2. #197
    Join Date
    Jan 2005
    Alicante (Spain)
    Quote Originally Posted by Louigi Verona
    the original tutorial that this scripts works basically for ANY type of files, not only for images.
    Only if modified since the script test to see if the file is an image.

  3. #198
    Join Date
    Mar 2005
    And how do you test file types anyway? For example if it's mp3 - also a popular file upload.

  4. #199
    Join Date
    Jan 2005
    Alicante (Spain)

  5. #200
    Join Date
    May 2008
    What the hell is a receiving directory??

    I keep getting that insufficient permission error.

  6. #201
    Join Date
    Mar 2005
    Quote Originally Posted by bokeh
    Read up on the mp3 format and then write a script to check the file structure matches that format.
    Yeah, actually I've been making certain read ups for quite some time now, but no luck so far. Though I did find classes to work with that but as I do have the upload code written by you and slightly modified by myself for my needs, I just want to incorporate the check into it and that's all.

    Afaik, checking for mime-type is not good for security, right?
    Last edited by Louigi Verona; 05-28-2008 at 08:54 AM.

  7. #202
    Join Date
    Mar 2005
    Quote Originally Posted by Vanterion
    What the hell is a receiving directory??

    I keep getting that insufficient permission error.
    Receiving dir is the one into which you upload your files. If it's permissions are set to read only, you can not write files into it.

  8. #203
    Join Date
    Jun 2008
    Just wanted to say a BIG ty to Bokeh. Someone wanted a place for people to submit their fan art and I set up the free Form M@iler script (which emails the file to you) which I realized left my hosts server COMPLETELY VULNERABLE to any type of upload.
    I managed to patch in Bokeh's script by putting it in front of the form M@ailer script.
    All I had to figure out was to put if ($_FILES[$fieldname]['tmp_name'] != '' ) { in front of the file check variables, and } at the end, then comment out the file storage commands so it went to the Form M@iler script instead

    took me ages but it was big fun

    -MrEd: )

  9. #204
    Join Date
    Jun 2008
    Hey all, I've cut and pasted all week to get the code to what I wanted, and I got it to work perfectly on my localhost, but when moving everything to public server I immediately bumped into problems.

    I want to make a new directory for each posting, and I do that like this:

    // Create new dir in img directory for each post
    $dirname = date("iBs", time());
    mkdir("img/$dirname", 0777);
    chmod("img/$dirname", 0777);

    // Make a note of the current working directory, relative to root.
    $directory_self = str_replace(basename($_SERVER['PHP_SELF']), '', $_SERVER['PHP_SELF']);

    // Make a note of the directory that will recieve the uploaded files.
    $uploadsDirectory = $_SERVER['DOCUMENT_ROOT'] . $directory_self . 'img/$dirname/';

    And I thought I could simply add $dirname/ to the $uploadsDirectory, but then I get the "receiving directory insuffiecient permission" warning further down in the code, so it's obviously not that easy.

    If I don't add $dirname/ everything works alright - the file transfer to the img folder - so I guess the $dirname/ is my issue... Do I have to chmod() that in some smart way as well, or?

    The '$dirname'-directory is created as it should 0777, sub-img...

    Last edited by staffstaff; 06-20-2008 at 02:01 PM.

  10. #205
    Join Date
    Jun 2008

    Maybe solved...

    aaaahhh, it's an UID /GID problem... need to configure php.ini as I read somewhere.

    Thank you to myself.

  11. #206
    Join Date
    Jul 2008
    I have problems with uploading images! I am not too new to PHP I just don't have any knowledge of file handling with PHP.

    I want user to input the paths to the images and id of a game (this is for a game database). And when user selects upload this script would create a directory (name would be an id that user entered) and inside that folder there are normal images and anoder directory with thumbnails (named thumbs).

    Here is the fun part! When a user selects game with that id script checks if there is a folder with that ID and then displays all that thumbnails with links to a full image. And images should be named like id_01,id_02,id_03....

    How can I do something like that?

  12. #207
    Join Date
    Mar 2006
    Liverpool, UK
    Hi all this script isd great thanks very much Bokeh. Unfortunately every now and then my client is experiencing problems with uploading an image and the latest one was the following:

    PHP Code:
    Fatal errorCall to undefined function: error() in
    :\Inetpub\vhosts\xxxx.com\xxxx\xxxx\xxxx\xxxx.php on line 56 
    which is the following few lines of code

    PHP Code:
    foreach($active_keys as $key

    $_FILES[$fieldname]['error'][$key] == 0
    error($_FILES[$fieldname]['tmp_name'][$key].': '.$errors[$_FILES[$fieldname]['error'][$key]], $uploadForm); 

    Can I just add that when Ive gone back into this and tried to upload the script the image is uploaded correctly. However the image is 1.8MB and is over 4000px wide and the client themselves admit that their internet line is not the strongest. Ive spoken to my server company and their maximum upload is 2MB so its not that!

    What Im wondering is the script timing out to give me this error or is there an error in the script that I am blind too?

    Any advice much appreciated!!

  13. #208
    Join Date
    Jan 2005
    Alicante (Spain)

  14. #209
    Join Date
    Mar 2006
    Liverpool, UK
    A while ago I asked you for a piece of script which ifd there was no image uploaded then the script would just exit i.e. this script also uploads an article and an article not always has an image hence we must exit the script. I think whats happening is that the script has timed out whist at this point in the script and hence when it gets to this point it looks like there is no image!! Does that make sense? As I say this isnt happening all the time only at certain points.



  15. #210
    Join Date
    Mar 2006
    Liverpool, UK
    Hi this is the script in regard to the error above. Now when I enter an image that is 4841 * 2102 Im getting the error mentioned above. However when I reduce the image to 2420 * 1050 the script runs fine. Now what Im wondering is there annything that I need to do to my ini file in regard to accept this type of image or would it be best to edit my file to make it less memory heavy! Any advice is greatly appreciated. I will have to send it in two parts unfortunately.

    PHP Code:



    if (
    $keywords=="") {
    $words=$title "," $articlekw;
    $p=". , : ; ' ? ! ( ) \" \\";
    $p=explode(" "$p);
    $p as $val){
    $words=str_replace($val," "$words);
    $words=explode(" "$words);
     foreach (
    $words as $val) {
      if (
    strlen($val)>3) {
       foreach (
    $commonwords as $comval) {
        if (
    $comval==$val) {
       if (
    $common!=true) {
        foreach (
    $keywords as $key => $value) {
    $keywordlist .= $key ", ";
     if (
    substr($keywordsstrlen($keywords), 1)==",") {
    $keywordlist=substr($keywords0, (strlen($keywords)-1));
    $keywords=str_replace("\n"" "$keywords);

    if (
    $description=="") {
    $sql="INSERT INTO article (title, aliases, author, createddate, publishingdate, description, keywords, article, catID, snippet, frontpage, scrollbar, email, display) VALUES ('$title', '$aliases', '$author', '$createddate', '$publishingdate', '$description', '$keywords', '$article', '$catID', '$snippet', '$frontpage', '$scrollbar', '$email', '$display')";
    $result=mysql_query($sql) or die ("Error!! BAD INSERT STATEMENT1!");

    $query="Select Max(articleID) AS articleID from article";
    $result=mysql_query($query) or die ("ERROR!! Unable to perform query!");

    $sql10="INSERT INTO article3 (articleID, title, aliases, author, createddate, publishingdate, description, keywords, article, catID, snippet, frontpage, scrollbar, email, display) VALUES ('$articleID', '$title', '$aliases', '$author', '$createddate', '$publishingdate', '$description', '$keywords', '$article', '$catID', '$snippet', '$frontpage', '$scrollbar', '$email', '$display')";
    $result10=mysql_query($sql10) or die ("Error!! BAD INSERT STATEMENT2!");
    The above part adds the article to the database. and the next post uploads the image
    Last edited by cs3mw; 07-23-2008 at 07:00 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.12515 seconds
  • Memory Usage 3,096KB
  • Queries Executed 15 (?)
More Information
Template Usage (38):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (3)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (15)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (15)postbit
  • (15)postbit_onlinestatus
  • (15)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (74):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates