File Upload Error

Discussion in 'HTML / PHP / JavaScript / CSS' started by Jaffa, Dec 30, 2009.

  1. Hi Again,
    I am trying to build an upload facility with PHP.I have it working perfectly on a WAMP server PHP5. But when I try and implement it here I am getting an error:

    Cannot open image file.PHP Warning: File upload error - unable to create a temporary file in Unknown on line 0
    PHP Warning: getimagesize(E:/web/gtphotograp/htdocs/test/Gallery/Fight1/Fight1_Sport3.jpg) [<a href='function.getimagesize'>function.getimagesize</a>]: failed to open stream: No such file or directory in E:\web\gtphotograp\htdocs\test\scripts\commonFunctions.php on line 107
    PHP Warning: imagecreatefromjpeg(E:/web/gtphotograp/htdocs/test/Gallery/Fight1/Fight1_Sport3.jpg) [<a href='function.imagecreatefromjpeg'>function.imagecreatefromjpeg</a>]: failed to open stream: No such file or directory in E:\web\gtphotograp\htdocs\test\scripts\commonFunctions.php on line 115
    PHP Warning: imagecreatetruecolor() [<a href='function.imagecreatetruecolor'>function.imagecreatetruecolor</a>]: Invalid image dimensions in E:\web\gtphotograp\htdocs\test\scripts\commonFunctions.php on line 122
    PHP Warning: Division by zero in E:\web\gtphotograp\htdocs\test\scripts\commonFunctions.php on line 123
    PHP Warning: Division by zero in E:\web\gtphotograp\htdocs\test\scripts\commonFunctions.php on line 124
    PHP Warning: Division by zero in E:\web\gtphotograp\htdocs\test\scripts\commonFunctions.php on line 133
    PHP Warning: imagecopyresampled(): supplied argument is not a valid Image resource in E:\web\gtphotograp\htdocs\test\scripts\commonFunctions.php on line 136

    From what I have been able to deduce Googling is that it has something to do with temporary file, but that is all I can work out.

    Anyone able to help?

    Thanks
     
  2. My php knowledge is a fraction of a click above zero but maybe it's related to the upload_tmp_dir setting in php.ini?
     
  3. mjp

    mjp

    Joe is probably on the right track.

    upload_tmp_dir has no value in our global php.ini, so any script that relies on that value will fail. You have to specifically define a target directory in your script.

    You cannot run your own version of php.ini on a shared Windows server the way you can on *nix/Apache, so I'm afraid you have to work around the php.ini limitations.
     
  4. Not sure how to do this. My understanding is that PHP creates a temp file eg. $_FILES['Filedata']['tmp_name'] this is stored in the temp dir until it is moved to the target directory. The temp dir is defined in the php.ini file and can't be overwritten with ini_set cause it is a system setting. So I am stumped.
    MJP are you able to offer a suggestion of how to write a target temp directory?

    eg the function to move a file is
    PHP:
    move_uploaded_file$_FILES['Filedata']['tmp_name'], /where/you/want/the/file/to/go/uploadedfile.ext);
    Thanks in advance
    Jaffa
     
  5. The issue is all sorted now, there was a problem with the permissions on the temp folder.
    Thanks to the Discount ASP support staff for their efforts, in fixing these issues, greatly appreciated.

    Jaffa
     
  6. mjp

    mjp

    Ah, good. Glad you got it sorted out.
     

Share This Page