WampServer 2.0 - File upload
Posted by: BakkerHenk (---.adsl-surfen.hetnet.nl)
Date: July 28, 2008 01:42PM

Hello all,

I have a little problem with file uploading.
I have installed wampserver 2.0.
Changed the php.ini (the correct one):
;;;;;;;;;;;;;;;;
; File Uploads ;
;;;;;;;;;;;;;;;;

; Whether to allow HTTP file uploads.
file_uploads = On

; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
upload_tmp_dir = "e:/wamp/uploads"

; Maximum allowed size for uploaded files.
upload_max_filesize = 8M

The specified directory ("e:/wamp/uploads"winking smiley exists and is writable.

Using the code below I tried to find the error.
  echo "Tempfile: ".$_FILES['uploadedfile']['tmp_name']."<Br>";
  echo "Tempfile size: ".$_FILES['uploadedfile']['size']."<br>";
  echo "Error: ".$_FILES['uploadedfile']['error']."<br><br>";

  echo "<pre>";
  print_r($_FILES);
  echo "</pre>";

The output I get when uploading a file is:

Tempfile: E:\wamp\uploads\php47.tmp
Tempfile size: 156420
Error: 0


Array
(
    [uploadedfile] => Array
        (
            [name] => tattoo2.jpg
            [type] => image/pjpeg
            [tmp_name] => E:\wamp\uploads\php47.tmp
            [error] => 0
             => 156420
        )

)

The tmp_name refers tot the directory set in the php.ini.
The problem however is that when I check the specified directory, the file is not there.
This of course causes the move_uploaded_file function to return an error.
Does someone know how to solve this problem?

Re: WampServer 2.0 - File upload
Posted by: Jamesking55 (---.range86-141.btcentralplus.com)
Date: July 28, 2008 04:16PM

Is Safe_Mode on or off?

Check Safe_Mode then Write Back

Re: WampServer 2.0 - File upload
Posted by: BakkerHenk (---.adsl-surfen.hetnet.nl)
Date: July 29, 2008 07:41PM

;
; Safe Mode
;
safe_mode = Off

Tried it with safe_mode off and on... both don't work

Re: WampServer 2.0 - File upload
Posted by: BakkerHenk (---.adsl-surfen.hetnet.nl)
Date: July 31, 2008 02:11PM

Found the problem.
The upload is going fine.
PHP removes tmp files immediately after execution of the requested php file.
My problem was caused by a false target path in the move_uploaded_file function.

Re: WampServer 2.0 - File upload
Posted by: harita (180.151.36.---)
Date: February 13, 2013 01:30PM

Where we have to write the code of changing temporary directry?
I need to know how to change the temporary directory to upload files?

Re: WampServer 2.0 - File upload
Posted by: guarienti (---.175.44.152.static.gvt.net.br)
Date: February 13, 2013 04:26PM

Hi,

if you need to change the default directory that PHP uses to store temporary uploaded files, you can change it on php.ini (W in tray icon -> PHP -> php.ini) (Be sure to BACKUP the file before changing anything):

; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
; [php.net]
upload_tmp_dir = "c:/wamp/tmp"

if what you need is to MOVE the file AFTER PHP placed it in the defautl directory, check this example by w3schools -> [www.w3schools.com]



Edited 1 time(s). Last edit at 02/13/2013 04:27PM by guarienti.

Sorry, only registered users may post in this forum.