Displaying pictures that are sourced from tmp files
Moderator: General Moderators
Displaying pictures that are sourced from tmp files
Dear All
I'm trying to preview pictures uploaded via the FILE input object method. With this method, PHP copies any selected files to a temp directory on the host machine. If you want to upload them, you then use the move_upload function.
I've tried uploading pictures using this method, then reading in the $_FILES['picName']['tmp_name'] to find the pathname of the temporary file (i.e. before using move_upload).
However, IE doesn't seem to like it, and whilst I put in
echo '<IMG SRC="'.$_FILES['picName']['tmp_name']'">'
IE seems to think it is a broken link, showing the characteristic 'X' symbol where the pictures are meant to load.
I've checked that $_FILES['picName']['tmp_name'] is correctly posted, and it is. However this still happens.
Could it be that IE doesn't like any files not ending in 'jpg' or 'gif'? The files are always initially copied to a temporary directory using the affix '.tmp'? Or is it some other problem?
Many thanks
Mark
I'm trying to preview pictures uploaded via the FILE input object method. With this method, PHP copies any selected files to a temp directory on the host machine. If you want to upload them, you then use the move_upload function.
I've tried uploading pictures using this method, then reading in the $_FILES['picName']['tmp_name'] to find the pathname of the temporary file (i.e. before using move_upload).
However, IE doesn't seem to like it, and whilst I put in
echo '<IMG SRC="'.$_FILES['picName']['tmp_name']'">'
IE seems to think it is a broken link, showing the characteristic 'X' symbol where the pictures are meant to load.
I've checked that $_FILES['picName']['tmp_name'] is correctly posted, and it is. However this still happens.
Could it be that IE doesn't like any files not ending in 'jpg' or 'gif'? The files are always initially copied to a temporary directory using the affix '.tmp'? Or is it some other problem?
Many thanks
Mark
You'll want to move it first, as http://php.net/manual/en/features.file-upload.php states,
"The file will be deleted from the temporary directory at the end of the request if it has not been moved away or renamed."
"The file will be deleted from the temporary directory at the end of the request if it has not been moved away or renamed."
Mark, in what form do I state the destination path on my site's server?
On the root directory of my server is the usual htdocs, logfiles, and private, but I have also created a directory called 'tmp' as well to upload pictures to.
How do I state this pathname for move_uploaded_files?
Also, another problem I seem to be having is that whilst I set the directory's attributes so that it is publicily writable, it seems to automatically put itself back to publicly unwritable without me requesting that it do so. Is this normal?
Many thanks
Mark
On the root directory of my server is the usual htdocs, logfiles, and private, but I have also created a directory called 'tmp' as well to upload pictures to.
How do I state this pathname for move_uploaded_files?
Also, another problem I seem to be having is that whilst I set the directory's attributes so that it is publicily writable, it seems to automatically put itself back to publicly unwritable without me requesting that it do so. Is this normal?
Many thanks
Mark
I'm using
But I'm getting the error message
Can anyone help?
Thanks and sorry for all the newbie questions.
Mark
Code: Select all
move_uploaded_file($_FILES['photo1_upload']['tmp_name'], "/tmp/");I think it's likely to do with the way I'm expressing the pathname for the 'tmp' directory on the root directory of my site's server (the same directory level as htdocs/private/logfiles) - that's why I'm asking about the nature of the pathname.Warning: move_uploaded_file(): Unable to move 'C:\WINDOWS\TEMP\php2B79.tmp' to '/tmp/' in \\nas09ent\domains\s\XXXX\user\htdocs\run2.php on line 2270
Warning: move_uploaded_file(/tmp/): failed to open stream: Invalid argument in \\nas09ent\domains\s\XXXXX\user\htdocs\run2.php on line 2271
Can anyone help?
Thanks and sorry for all the newbie questions.
Mark
Mark - I'm now getting this:
Warning: move_uploaded_file(/tmp/): failed to open stream: Invalid argument in \\nas09ent\domains\s\XXXX\user\htdocs\run2.php on line 2270
Warning: move_uploaded_file(): Unable to move 'C:\WINDOWS\TEMP\php2B8D.tmp' to '\\\\nas09ent\\domains\\s\\XXXX\\user\\htdocs\\run2.php/tmp/big.jpg' in \\nas09ent\domains\s\XXXX\user\htdocs\run2.php on line 2270
Yes it is IIS.
So I take it the pathname I should state should be -
\\\\nas09ent\\domains\\s\\XXXX\\user\\tmp\\<original filename>
?
Because apparently this doesn't work. Although it doesn't produce an error message, when I check the tmp directory for the file the directory is empty.
Also, I notice that even though I change the attributes to allow public read/write of this directory, they seem to change back to disallowing public access on their own at some point without my interference.
Any ideas?
So I take it the pathname I should state should be -
\\\\nas09ent\\domains\\s\\XXXX\\user\\tmp\\<original filename>
?
Because apparently this doesn't work. Although it doesn't produce an error message, when I check the tmp directory for the file the directory is empty.
Also, I notice that even though I change the attributes to allow public read/write of this directory, they seem to change back to disallowing public access on their own at some point without my interference.
Any ideas?