close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Image upload not working

Thread began 4/06/2012 2:04 pm by turbo.sarajevo416658 | Last modified 4/09/2012 12:35 pm by Jason Byrnes | 1853 views | 11 replies |

turbo.sarajevo416658

Image upload not working

Hi,
i have the following problem on my local machine. I used data assist for the results, delete and insert pages. When i insert a record (with an image upload field) with an image which size is about 200KB everything is working great (database insert and upload to a folder) but when i try to insert and upload images which size is about 3 or 4 MB it is not working. In firefox i can only see "waiting for localhost". I tried to change everything in my php.ini but it is still not working.

PHP.INI settings--------------------------------------------------------------------

;;;;;;;;;;;;;;;;
; File Uploads ;
;;;;;;;;;;;;;;;;

; Whether to allow HTTP file uploads.
; file-uploads
file_uploads = On

; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
; upload-tmp-dir
upload_tmp_dir = "c:/wamp/tmp"

; Maximum allowed size for uploaded files.
; upload-max-filesize
upload_max_filesize = 100M
post_max_size = 100M

...


Page--------------------------------------------------------------------------


<?php require_once("../WA_DataAssist/WA_AppBuilder_PHP.php"); ?>
<?php require_once("../webassist/file_manipulation/helperphp.php"); ?>
<?php
// WA_UploadResult1 Params Start
$WA_UploadResult1_Params = array();
// WA_UploadResult1_1 Start
$WA_UploadResult1_Params["WA_UploadResult1_1"] = array(
'UploadFolder' => "../Slike galerija/",
'FileName' => "[FileName]",
'DefaultFileName' => "",
'ResizeType' => "3",
'ResizeWidth' => "0",
'ResizeHeight' => "600",
'ResizeFillColor' => "" );
// WA_UploadResult1_1 End
// WA_UploadResult1 Params End
?>
<?php
WA_DFP_SetupUploadStatusStruct("WA_UploadResult1");
if($_SERVER["REQUEST_METHOD"] == "POST"){
WA_DFP_UploadFiles("WA_UploadResult1", "path", "2", "[NewFileName]_[Increment]", "false", $WA_UploadResult1_Params);
}
?>
<?php
// WA Application Builder Insert
if (isset($_POST["Insert_x"])) // Trigger
{
$WA_connection = $Ambasada;
$WA_table = "slike";
$WA_sessionName = "WADA_Insert_slike";
$WA_redirectURL = "slike_Results.php";
if (function_exists("rel2abs")) $WA_redirectURL = $WA_redirectURL?rel2abs($WA_redirectURL,dirname(__FILE__)):"";
$WA_keepQueryString = false;
$WA_indexField = "slika_id";
$WA_fieldNamesStr = "naziv|path";
$WA_fieldValuesStr = "".((isset($_POST["naziv"]))?$_POST["naziv"]:"") ."" . "|" . "".$WA_DFP_UploadStatus["WA_UploadResult1"]["serverFileName"] ."";
$WA_columnTypesStr = "',none,''|',none,''";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode("|", $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_connectionDB = $database_Ambasada;
mysql_select_db($WA_connectionDB, $WA_connection);
if (!session_id()) session_start();
$insertParamsObj = WA_AB_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, -1);
$WA_Sql = "INSERT INTO `" . $WA_table . "` (" . $insertParamsObj->WA_tableValues . ") VALUES (" . $insertParamsObj->WA_dbValues . ")";
$MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
$_SESSION[$WA_sessionName] = mysql_insert_id();
if ($WA_redirectURL != "") {
if ($WA_keepQueryString && $WA_redirectURL != "" && isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] !== "" && sizeof($_POST) > 0) {
$WA_redirectURL .= ((strpos($WA_redirectURL, '?') === false)?"?":"&").$_SERVER["QUERY_STRING"];
}
header("Location: ".$WA_redirectURL);
}
}
?>



It also doesn&#269;t matter if i remove the resize behavior or upload a file with any other extension.

Please help, thanks in advance...

Sign in to reply to this post

Jason ByrnesWebAssist

after changing the settings in the php.ini file, did you restart the apache server?

are you sure you edited the correct file?

create a new php page and add the following code to it:

php:
<?php phpinfo(); ?>




this will show you the active settings that the server is using, do your changes show in the phpinfo page?

see this page for details on all the php settings that effect file upload size:
wap_upload.asp?page=php2

Sign in to reply to this post

turbo.sarajevo416658

Still not working

I'm sure that i edited the loaded ini file. I restarted apache and even my pc. I also did everything on this link that you provided. But, now i found out that files over 1MB are not accepted. 990 KB is fine but 1050 KB is not working ... I cant find the problem. I'm using wamp with
Apache Version :
2.2.17
PHP Version :
5.3.4

Sign in to reply to this post

Jason ByrnesWebAssist

did you create the phpinfo page?

do you see the changes taking effect in the phpinfo page?

the phpinfo page will also tell you where the php.ini file that is being used is located to make sure you are editing the correct one.

bottom line is:
if some files are being accepted, but not others, it is a server configuration issue.

Sign in to reply to this post

turbo.sarajevo416658

I have created the phpinfo page and everything seems to be fine, but the problem is still there. Ok, at least I'm glad to know that it has nothing to do with my upload page. I will once more try to google my problem as a wamp or apache isssue ... Thank you.

Sign in to reply to this post

Jason ByrnesWebAssist

to help troubleshoot, try adding the following code at line 1 to turn on error reporting:

php:
<?php

error_reporting
(E_ALL);
ini_set('display_errors','on');
?>



change the following line:
$WA_redirectURL = "slike_Results.php";

to:
$WA_redirectURL = "";

so that it will no longer redirect.

go to the bindings panel and expand the WA Uploaded Files section add the debug info binding to the page just before the closing the </body> tag.

also add this code just before the closing </body> tag:

php:
<pre><?php var_dump($_POST); ?></pre>

<pre><?php var_dump($_FILES); ?></pre>



and try uploading a file that failed before, this might give us some information to go on.

Sign in to reply to this post

turbo.sarajevo416658

Firefox just shows waiting for localhost and it never ends (no errors or blank pages) but in chrome and ie, when i do what you told me to, i get this:





Status object: WA_UploadResult1
statusCode : 0
errorMessage : No file uploaded
clientFileName :
fileExtension :
serverFileName :
serverSimpleFileName :
serverDirectory :
contentType :
fileWasOverwritten :
fileWasSkipped :
fileWasRenamed :
fileSize : -1
isImage :
imageWidth : -1
imageHeight : -1
WA_UploadResult1_1:
clientFileName :
fileExtension :
serverFileName :
serverSimpleFileName :
serverDirectory :
contentType :
fileSize : -1
imageWidth : -1
imageHeight : -1
statusCode : 0
errorMessage : No file uploaded
array
'naziv' => string 'fdsafsdf' (length=8)
'Insert_x' => string '20' (length=2)
'Insert_y' => string '11' (length=2)
'Insert' => string 'Insert' (length=6)
'WADAInsertRecordID' => string '' (length=0)
array
'path' =>
array
'name' => string 'IMG_1114.jpg' (length=12)
'type' => string '' (length=0)
'tmp_name' => string '' (length=0)
'error' => int 1
'size' => int 0

Sign in to reply to this post

turbo.sarajevo416658

Also i forgot, when the upload is successful i get this (this is the same page)

Status object: WA_UploadResult1
statusCode : 1
errorMessage :
clientFileName : 3721428_460s.jpg
fileExtension : jpg
serverFileName : 3721428_460s_1.jpg
serverSimpleFileName : 3721428_460s_1
serverDirectory : C:\wamp\www\ABC\Slike galerija\
contentType : image/jpeg
fileWasOverwritten :
fileWasSkipped :
fileWasRenamed : 1
fileSize : 194017
isImage :
imageWidth : -1
imageHeight : -1
WA_UploadResult1_1:
clientFileName : 3721428_460s.jpg
fileExtension : jpg
serverFileName : 3721428_460s_1.jpg
serverSimpleFileName : 3721428_460s_1
serverDirectory : C:\wamp\www\ABC\Slike galerija\
contentType : image/jpeg
fileSize : 194017
imageWidth : -1
imageHeight : -1
fileWasOverwritten :
fileWasSkipped :
fileWasRenamed : 1
statusCode : 1
array
'naziv' => string 'dfds' (length=4)
'Insert_x' => string '40' (length=2)
'Insert_y' => string '22' (length=2)
'Insert' => string 'Insert' (length=6)
'WADAInsertRecordID' => string '' (length=0)
array
'path' =>
array
'name' => string '3721428_460s.jpg' (length=16)
'type' => string 'image/jpeg' (length=10)
'tmp_name' => string 'C:\wamp\tmp\php66A8.tmp' (length=23)
'error' => int 0
'size' => int 194017

Sign in to reply to this post

Jason ByrnesWebAssist

so in the files array:
array
'path' =>
array
'name' => string 'IMG_1114.jpg' (length=12)
'type' => string '' (length=0)
'tmp_name' => string '' (length=0)
'error' => int 1
'size' => int 0

it is showing the error:
'error' => int 1


with a value of 1

according to this page on the php site:
features.file-upload.errors.php


the error value of 1 means that it exceeds the upload_max_filesize

  UPLOAD_ERR_INI_SIZE
Value: 1; The uploaded file exceeds the upload_max_filesize directive in php.ini.  






if you look at the page i linked to before carefully:
wap_upload.asp?page=php2

it says the the upload_max_filesize should be set in bytes, but you are using:
upload_max_filesize = 100M

which is not correct. change that to;


upload_max_filesize = 104857600

Sign in to reply to this post

turbo.sarajevo416658

This is not the problem. I changed it and it remains the same. But even if i leave it default (2MB) i can not upload files larger than 1 MB. I just reinstalled, wamp and automatically reinstalled mysql, php and apache and left everything by default and i still have the same issue...

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...