473,382 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Image problem with $_FILES and $_POST

Hello again.
I have a form for posting news articles.

Form one is the "register" form.
Then I go to the preview form were I can select edit or accept

If I select edit, I got the "edit form" and if I select accept, I
receive a message that say:

The news article "headline" are posted into the database.

When I use the file field and browse to "my photos", select an image
and post it. I can see it in the priview form/page and can also show
it in the article.

But if I select the "edit" button I can't see the image.
I am using <input type="hidden" name="article_photo"
value="$article_foto"field to preserve the value of the field:
<input type="file" name="article_photo">

Well. I discover that if I not have anything in the field <input
type="file" name="article_photo"...
but still have the image.jpg in the hidden field. It use the
$_POST["article_photo"] insted of
$_FILES["article_photo"];

So I was thinking that this below should do the trick:

if(!isset($_FILES["article_photo"])){
$article_photo = $_POST["article_photo"];
} else {
$article_photo = $_FILES["article_photo"];
}

But still the image are not avaible in the edit or preview pages in
the variable $article_photo
BUT if I use the file field and browse, select an image and post it.
Then it show up in those pages.

How can I fix this? Is it better to use setcookie("article_photo",
$_POST['article_photo'] time()+30);

Thanks for all advice. (and sorry my weak english)

Karl
Dec 29 '07 #1
5 2560
Karl wrote:
Hello again.
I have a form for posting news articles.

Form one is the "register" form.
Then I go to the preview form were I can select edit or accept

If I select edit, I got the "edit form" and if I select accept, I
receive a message that say:

The news article "headline" are posted into the database.

When I use the file field and browse to "my photos", select an image
and post it. I can see it in the priview form/page and can also show
it in the article.

But if I select the "edit" button I can't see the image.
I am using <input type="hidden" name="article_photo"
value="$article_foto"field to preserve the value of the field:
<input type="file" name="article_photo">

Well. I discover that if I not have anything in the field <input
type="file" name="article_photo"...
but still have the image.jpg in the hidden field. It use the
$_POST["article_photo"] insted of
$_FILES["article_photo"];

So I was thinking that this below should do the trick:

if(!isset($_FILES["article_photo"])){
$article_photo = $_POST["article_photo"];
} else {
$article_photo = $_FILES["article_photo"];
}

But still the image are not avaible in the edit or preview pages in
the variable $article_photo
BUT if I use the file field and browse, select an image and post it.
Then it show up in those pages.

How can I fix this? Is it better to use setcookie("article_photo",
$_POST['article_photo'] time()+30);

Thanks for all advice. (and sorry my weak english)

Karl
Do you have the image file name in a <img...tag?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Dec 29 '07 #2
On 29 Des, 15:54, Jerry Stuckle <jstuck...@attglobal.netwrote:
Karl wrote:
Hello again.
I have a form for posting news articles.
Form one is the "register" form.
Then I go to the preview form were I can select edit or accept
If I select edit, I got the "edit form" and if I select accept, I
receive a message that say:
The news article "headline" are posted into the database.
When I use the file field and browse to "my photos", select an image
and post it. I can see it in the priview form/page and can also show
it in the article.
But if I select the "edit" button I can't see the image.
I am using <input type="hidden" name="article_photo"
value="$article_foto"field to preserve the value of the field:
<input type="file" name="article_photo">
Well. I discover that if I not have anything in the field <input
type="file" name="article_photo"...
but still have the image.jpg in the hidden field. It use the
$_POST["article_photo"] insted of
$_FILES["article_photo"];
So I was thinking that this below should do the trick:
if(!isset($_FILES["article_photo"])){
$article_photo = $_POST["article_photo"];
} else {
$article_photo = $_FILES["article_photo"];
}
But still the image are not avaible in the edit or preview pages in
the variable $article_photo
BUT if I use the file field and browse, select an image and post it.
Then it show up in those pages.
How can I fix this? Is it better to use setcookie("article_photo",
$_POST['article_photo'] time()+30);
Thanks for all advice. (and sorry my weak english)
Karl

Do you have the image file name in a <img...tag?
Yes, I have.

And it works if I use the <input type="file" name="article_photo">
field.
$article_photo = $_FILES["article_photo"]; make it work.
But when I have the image.jpg registred in a <input type="hidden"...
field, it does not work.

I think that this hidden field use the $_POST["article_photo"]
instead of $_FILES["article_photo"] because if i "comment out" the
$_FILES... line and insted use $_POST["article_photo"] I can find it..
But then the file field not work..

Karl
Dec 29 '07 #3
Karl wrote:
On 29 Des, 15:54, Jerry Stuckle <jstuck...@attglobal.netwrote:
>Karl wrote:
>>Hello again.
I have a form for posting news articles.
Form one is the "register" form.
Then I go to the preview form were I can select edit or accept
If I select edit, I got the "edit form" and if I select accept, I
receive a message that say:
The news article "headline" are posted into the database.
When I use the file field and browse to "my photos", select an image
and post it. I can see it in the priview form/page and can also show
it in the article.
But if I select the "edit" button I can't see the image.
I am using <input type="hidden" name="article_photo"
value="$article_foto"field to preserve the value of the field:
<input type="file" name="article_photo">
Well. I discover that if I not have anything in the field <input
type="file" name="article_photo"...
but still have the image.jpg in the hidden field. It use the
$_POST["article_photo"] insted of
$_FILES["article_photo"];
So I was thinking that this below should do the trick:
if(!isset($_FILES["article_photo"])){
$article_photo = $_POST["article_photo"];
} else {
$article_photo = $_FILES["article_photo"];
}
But still the image are not avaible in the edit or preview pages in
the variable $article_photo
BUT if I use the file field and browse, select an image and post it.
Then it show up in those pages.
How can I fix this? Is it better to use setcookie("article_photo",
$_POST['article_photo'] time()+30);
Thanks for all advice. (and sorry my weak english)
Karl
Do you have the image file name in a <img...tag?

Yes, I have.

And it works if I use the <input type="file" name="article_photo">
field.
$article_photo = $_FILES["article_photo"]; make it work.
But when I have the image.jpg registred in a <input type="hidden"...
field, it does not work.

I think that this hidden field use the $_POST["article_photo"]
instead of $_FILES["article_photo"] because if i "comment out" the
$_FILES... line and insted use $_POST["article_photo"] I can find it..
But then the file field not work..

Karl
OK, did you write this yourself? Or is this someone else's script?

If the latter, that's who you should be asking.

And <input type="file"...and <input type="hidden"...have two
entirely different uses.

And sure - if you comment out the $_FILES line, there is no way for the
file field will work.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Dec 29 '07 #4
On 29 Des, 19:51, Jerry Stuckle <jstuck...@attglobal.netwrote:
>
OK, did you write this yourself? Or is this someone else's script?
No it's mine :)
>
If the latter, that's who you should be asking.

And <input type="file"...and <input type="hidden"...have two
entirely different uses.
Yes, I know.
And sure - if you comment out the $_FILES line, there is no way for the
file field will work.
Yes, of course. I do it just to try what would happen.

Anyway. If I select to post the image.jpg by the file field on the
"edit" page. It work.
I had hoped to find a way to "transfer" it through this different view
of forms without post it a second time.

Karl
Dec 29 '07 #5
Karl wrote:
On 29 Des, 19:51, Jerry Stuckle <jstuck...@attglobal.netwrote:
>OK, did you write this yourself? Or is this someone else's script?

No it's mine :)
>If the latter, that's who you should be asking.

And <input type="file"...and <input type="hidden"...have two
entirely different uses.
Yes, I know.
>And sure - if you comment out the $_FILES line, there is no way for the
file field will work.

Yes, of course. I do it just to try what would happen.

Anyway. If I select to post the image.jpg by the file field on the
"edit" page. It work.
I had hoped to find a way to "transfer" it through this different view
of forms without post it a second time.

Karl
OK, this is a little more clear now.

The only way you can get data from one page to another is either via a
form field or the $_SESSION variable.

In a case like this, I'd just use the hidden field to pass the old name.
If the user uploads a new file, use it. Otherwise just use the old
file (the one passed in the hidden field).

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Dec 29 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: dave | last post by:
Hello there, I am at my wit's end ! I have used the following script succesfully to upload an image to my web space. But what I really want to be able to do is to update an existing record in a...
9
by: pescott | last post by:
Hello people, I could really use your help on this one... I have script to upload image data to a database, but all that is uploaded is the decription, not the data BLOB itself. There must be...
7
by: pescott | last post by:
I am still struggling to get some files uploaded to a database as BLOB data. I have 5 includes which allows the user to upload 5 files, numbered accordingly. However, there are script errors. Duhh,...
0
by: doffer | last post by:
I want to make a portfoliosystem where user can register and get their own portfolio... I've started the developer work, but I'm stuck on the image upload part... I'm experiencing some problems...
1
by: Glenn Coyle | last post by:
Hi I am having trouble writing the file path of a image to the database,also for some reason it is not uploading the images, anyone have any ideas? the code is below: if($_POST ==...
12
by: Shawn Northrop | last post by:
Ive been searching for an image resize tutorial for a while now and found this code which worked nicely. I was unable to find the full source code but i think i pieced together the code from the...
7
by: xx75vulcan | last post by:
Hi, I've got a PHP Upload Form that works great, unless that is, the image your uploading has been modified through a photo editing software. Example: if I upload the image straight from a...
2
by: mac | last post by:
Hi, I'm looking for a script that will allow me to upload images to a folder and shows pagination... pls can any body help me? i hav done with the uploading, but not able to do with the...
1
by: chennaibala | last post by:
can any one send me mutiple image upload program and save the file name with extension in mysql table.we must cheak uploaded file type like bmp or any image file while uploading. i develop...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.